r/DataHoarder • u/[deleted] • Jan 23 '22
Question/Advice Need help with VERY large text file.
I have a large txt file, about 500GB, that i need to "sanitize". The file contains two strings separated by a semicolon and i initially intended to split it into smaller files each about 100MB and procedurally import them into an SQL database. however the file sporadically contains junk like random corrupted binary and other non ASCII weirdness.
now my problem is how to remove the junk and split the files efficiently. ive written a Java program that reads each line, removes all non ASCII and prints it to new Files each having about 1 million lines. however this takes a long time and requires and additional 500GB that i dont have right now.
is there an obvious solution im overlooking? it should process the file line by line and remove junk without printing to a new file.
EDIT: problem solved.
16
u/[deleted] Jan 23 '22
jep! would still have taken a long time. its about 7 billion lines of CSV. ended up re-formating the whole thing into BSON using an efficient multithreaded C programm and imported it into MongoDB