Computing.Net > Forums > Unix > Script to process/search a csv file

Script to process/search a csv file

Reply to Message Icon

Original Message
Name: catcher
Date: June 2, 2003 at 18:59:26 Pacific
Subject: Script to process/search a csv file
OS: Unix 5.0
CPU/Ram: 2.7G
Comment:

I want to write a csh script to search files "Scan_ddmmyy.csv" placed in a directory. The program should look for EXCLUSIVE flags in the 6th, 7th & 8th fields(0/1- Assume exclusive here for simplicity).The records in Scan*.csv files are to be placed in subdirs A/B/C based on these flags. In case all flags are 0 delete that record. The individual records are thus placed in new files "ScanA/B/C_seq.csv" within the subdirs A/B/C with each file containing a max of 50 records, nd filename with _seq.csv where seq=sequence number of the file.
Please email me with suggestions at: amieyap@hotmail.com Thanks.


Report Offensive Message For Removal

Response Number 1
Name: David Perry
Date: June 3, 2003 at 04:29:31 Pacific
Subject: Script to process/search a csv file
Reply: (edit)

Unless you are working under the contraints of a homework assignment, it is a bad idea to write scripts in csh.

http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/

If you would like to write such a script, please do. If you have difficulty, please post what you have done so far with questions about the trouble spots.


Report Offensive Follow Up For Removal

Response Number 2
Name: WilliamRobertson
Date: June 3, 2003 at 10:36:04 Pacific
Subject: Script to process/search a csv file
Reply: (edit)

awk is pretty good at this kind of thing, e.g. if testit.dat contains

one,two,three,four
a,b,c,d
banana,fruitcake,piano,hatstand

then

awk -F',' '{print $2,$3}' testit.dat

gives

two four
b d
fruitcake hatstand

btw, if you name the files "scan_yyyymmdd.csv" they can be easily sorted in date order.



Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Script to process/search a csv file

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software