HI all, I can pass a gzipped file to .Q.fsn? Or maybe zipped file?
no. There are ways to extend kdb+ with a custom shared lib that reads from named pipes, but you can also unzip to stdout and pipe that into kdb+ via a callback via java, e.g.
import java.net.*;
import java.io.*;
import kx.c;
public class Pipe {
public static void main(String args) throws Exception {
c c=new c(“127.0.0.1”,5000,“username:password”);
BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
StringBuilder sb = new StringBuilder(2000000);
String inputLine;
int lc=0;
if((inputLine=in.readLine())!=null){
c.ks(“{t set{flip x!count[x]#()}
$","vs x}”,inputLine.toCharArray()); // create empty untyped table with headers
c.ks(“upd:{t,:flip("JSSJJJJJFJFJJFFSSJ";",")0:x}”); // specify update fn with types
}
while((inputLine=in.readLine())!=null){
sb.append(inputLine);
sb.append(“\n”);
if(lc++>5000){ // bulk load 5000 lines in each msg
lc=0;
c.ks(“upd”,sb.toString().toCharArray());
sb=new StringBuilder(2000000);
}
}
if(lc>0)
c.ks(“upd”,sb.toString().toCharArray());
in.close();
c.close();
}
}
then
gunzip -c test.csv.gz | java Pipe
as usual, you’d want to add proper error checking to the above!
This can be easily changed to support fixedwidth too.