![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Processing a CSV file | janemary.a | High Level Programming | 1 | 05-11-2007 07:27 AM |
| Using loop reading a file,retrieving data from data base. | Sonu4lov | Shell Programming and Scripting | 1 | 01-19-2007 03:38 AM |
| Have a shell script check for a file to exist before processing another file | heprox | Shell Programming and Scripting | 3 | 11-14-2006 03:26 AM |
| data processing | rochitsharma | UNIX for Advanced & Expert Users | 5 | 06-14-2006 05:13 AM |
| processing data in a flat file | wolkott | Shell Programming and Scripting | 4 | 01-27-2003 01:57 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Data File Processing Help
I need to read contents of directory and create a list of data files that match a certain pattern and process by renaming it and calling a existing .ksh script then archiving off to file another directory. Any suggestions or samples u could point me to on using .ksh perl or other to process through the list of data files? What would you recommend to strip off a suffix from a data file?. tia
|
|
||||
|
file names:
BTIME_ACTUAL_WORK_HRS_wk_45_to_46.csv BTIME_ACTUAL_WORK_HRS_wk_46_to_47.csv ... sample processing: 1) strip off/rename each data file e.g. BTIME_ACTUAL_WORK_HRS_wk_45_to_46.csv to BTIME_ACTUAL_WORK_HRS.csv 2) call existing .ksh script (it will reference BTIME_ACTUAL_WORK_HRS.csv) each time 3) move/copy of BTIME_ACTUAL_WORK_HRS_wk_45_to_46.csv moved to /archive directory. 4) process next file Ensure each file is only processed once Copy of originally named file is archived Process only non-zero byte files or wc > 3 Assumes job will be called from scheduler when files are ready/waiting tia |
|
||||
|
I would humbly suggest you fix the existing ksh script to accept a file name argument. This is begging for ending up in a situation where you are not sure which file you have processed. Code:
for f in BTIME_ACTUAL_WORK_HRS_*.csv; do cp -f "$f" BTIME_ACTUAL_WORK_HRS.cvs horrendous_legacy.ksh --majestic --righteous # FIXME: make it accept name of csv file mv "$f" archive/ # assume it's not really /archive/ done Hate to break this to you, but error handling left as an important exercise. Last edited by era; 03-27-2008 at 04:42 PM.. Reason: Double quotes around file name variable, just to be a model citizen |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|