in reply to split large CSV file >9.1MB into files of equal size that can be opened in excel
You have a choice when splitting a file; split on its physical size, or split on its logical structure. If you wish to treat each half as its own unit, you have to split logically. Splitting blindly on size only works if you intend to reassemble them later.
To split on logical units that closely approximate physical size, read half the physical file size, then continue forward until you hit the next logical break, and split there.
If you choose to read half, then continue forward, you can either continue byte by byte until you find a record separator. That's not the most efficient approach though. It's often more efficient to read in, say, 4kb or 8kb segments, and then split those segments on the first record separator found. Once you perform that split, append the left-hand of the split to the first document, and prepend the right-hand of the split to the second document. Then read the entire remainder into the 2nd document.
Dave
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: split large CSV file >9.1MB into files of equal size that can be opened in excel
by pryrt (Abbot) on Sep 28, 2016 at 23:52 UTC | |
by davido (Cardinal) on Sep 29, 2016 at 01:10 UTC |