splitting csv file

Richard Kreiss rkreiss at gccconsulting.net
Wed Jan 8 07:59:17 PST 2014



> -----Original Message-----
> From: filepro-list-bounces+rkreiss=verizon.net at lists.celestial.com
> [mailto:filepro-list-bounces+rkreiss=verizon.net at lists.celestial.com] On
> Behalf Of scooter6 at gmail.com
> Sent: Wednesday, January 08, 2014 9:39 AM
> To: filepro-list at lists.celestial.com
> Subject: OT: splitting csv file
> 
> I have a csv file that looks something like this:
> 
> 12/5/2013,14:12,,1,2,3,14160.00,,,,profdm1,,,property,   etc
> 12/5/2013,14:12,,1,2,3,14160.00,,,,,,,,property, etc
> 
> There are and can be several lines in this file.
> 
> What I want to do is split this file into multiple files based on ONE factor alone.
> Field 12 (where is has  profdm1 in line 1) If that field has a value, I want that
> line and all subsequent lines below it where field 12 is null to be split into a
> file, then when it encounters field 12 has a value in it, create a new file and
> repeat this process thru the end of the file....
> 
> So the original file may have, for example, 5 lines where field 12 has a
> value....so this process should split the csv file into 5 files.....each having the
> line where field 12 has a value and ALL other lines below it, UNTIL it finds the
> next line where field 12 has a value....
> 
> I have looked at awk/gawk and don't see anywhere that you can set
> parameters to do this...
> Perhaps Perl?
> 
> Hoping someone has had to do something like this before and knows a good
> solution...
> 
> thanks
> 
> Scott
> PDM

My suggestion would be to build a demand index, sorted first on field 12.  

The process can be done from either *report or *clerk while sitting on one record. Create a process to do  a lookup to each record, export it, close it, and do a lookup next, reset the export file name, and export the next record until all records have been processed.


Richard Kreiss
GCC Consulting

Office: 410-653-2813








More information about the Filepro-list mailing list