Hi Phil,
Notepad can easily handle 3 to 4 MB, easily
so I would not split all of that in tiny little files, because the thousands of files extracted from a gigabyte file,
will do your windows more harm than a 4MB file will do your Notepad
You will have to iterate.
In an old file I have from you, 500 lines will mean 2.5MB
You will have to run and see what the average line size is
That is the matimatical rule of 3,
run the program, see how much MB 500 lines are, set the Block_size constant to a number you need to get 4MB and run again
I have changed the dump_in_file method to do zero padding in the file name, now they all sort correctly in the dir list.
Pick your resulting file size large enough (4 MB will give uyou about 300 result files) in order to not have to start working with subdirs
have fun
1:
2:
3:
4:
5:
6:
7:
|
def dump_in_file (lar, lno)
lnos = sprintf("%06d", lno)
res = File.open("F:\\12_Ruby\\large\\part_#{lnos}.txt", "w")
lar.each do |a|
res.puts a
end
end
|
Open in New Window
Select All