Forums Register Login

Read a file and write them into different files based on unique words in each line

+Pie Number of slices to send: Send
Input to the program would be start and end position of the unique word in each line from db and a text file.

For example: for the below input file start position is 0 and end position is 6 which is ABCDEF,store this value and compare with the first 6 characters in second line ifs its same copy them into same file else copy them into another file.For every file there can be 'n' no unique words ,n different files need to be created dynamically.positions will change file to file.The file size can be more than 10gb

Original input file: originalfile.txt ABCDEF aksjlnf woeirf 234 1234

FJHIJK sdfdf 3412344 124

ABCDEF asdhgbfl 3 agagd

FJHIJK agagafg 1 agag

output should be:splitfile1.txt

ABCDEF aksjlnf woeirf 234 1234

ABCDEF asdhgbfl 3 agagd

splitfile2.txt FJHIJK sdfdf 3412344 124

FJHIJK sdfdf 3412344 124
+Pie Number of slices to send: Send
Welcome to the Ranch!

What have you done so far? Post your code and please UseCodeTags (← that's a link).
It's a tiny ad only because the water is so cold.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 304 times.
Similar Threads
Reading a CSV file--> Fastest way
Fresh Meat - Extremely Simple Numerology Word Processing Program - Assistance Requested!
Writing a file and executing
Multiple Execution of the Same Program Writing on the Same file
Hash Map to do Inverted Index?
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 06:17:45.