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

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Script to process/search a csv file

Reply to Message Icon

Name: catcher
Date: June 2, 2003 at 18:59:26 Pacific
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.



Sponsored Link
Ads by Google

Response Number 1
Name: David Perry
Date: June 3, 2003 at 04:29:31 Pacific
Reply:

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.


0

Response Number 2
Name: WilliamRobertson
Date: June 3, 2003 at 10:36:04 Pacific
Reply:

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.



0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Script to process/search a csv file

Script to Read a .CSV file www.computing.net/answers/unix/script-to-read-a-csv-file-/7784.html

shell script to check for a file on www.computing.net/answers/unix/shell-script-to-check-for-a-file-on/3714.html

Script to extract a word from file www.computing.net/answers/unix/script-to-extract-a-word-from-file/8081.html