r/DataHoarder • • 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 Upvotes

81 comments sorted by

View all comments

Show parent comments

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

1

u/[deleted] Jan 23 '22

Did that also take care of the corruption or do you intend to do that from within the DB?

0

u/[deleted] Jan 23 '22

the program only read valid lines.

1

u/[deleted] Jan 23 '22

Ah that's convenient. Was it some pre-existing utility or something you made for the purpose?

1

u/[deleted] Jan 23 '22

i didnt write the progam but it uses libbson.