I have a file that records terminated by "\n" and columns terminated by X"01", the first non printing character. And it is big... 7GB which will totally screw my laptop memory.
I have done some google around how to read big file line by line by using BufferReader
.. etc.
But the definition of LINE is a bit different, the readline function will return the line that either ends with "\n", "^M" ..etc.
I am wondering is there a solution in Java 6/7 to read big files line by line, whose definition is the line end with \n ONLY.
Thanks!
I have a sample data set here and wondering if some one who could run against the sample data and extract the first column timestamp of every line.
here is what I have done but it only reads in the first line,
import java.io.File;
import java.io.IOException;
import java.util.Scanner;
public class ParseAdafruit {
public static void main(String[] args) throws IOException {
// Predefine the delimiter ^A
String delimiter = String.valueOf((char) 1);
Scanner scanner = new Scanner(new File("/Users/.../data")).useDelimiter("\\n");
while (scanner.hasNext()) {
String line = scanner.next(); // This is your line
String[] parts = line.split(delimiter);
System.out.println(parts[0]);
}
}
}
Output
2014-01-28 18:00:41.960205
btw, I had such a good time in Python by using something like this:
for line in sys.stdin:
print line.split(chr(1))[0]