The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



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

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-27-2008
mavsman mavsman is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 17
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
  #2 (permalink)  
Old 03-27-2008
mavsman mavsman is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 17
test message
  #3 (permalink)  
Old 03-27-2008
joeyg's Avatar
joeyg joeyg is offline Forum Staff  
modérateur
  
 

Join Date: Dec 2007
Location: Home of 17-time world champion Boston Celtics
Posts: 1,311
Question Easier to understand with sample data - input & output

Please supply input files, data and desired results. It is much easier to understand from data rather than describing the situation.

To handle filename issues, do a >man basename
not clear exactly what you are trying to do.
  #4 (permalink)  
Old 03-27-2008
mavsman mavsman is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 17
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
  #5 (permalink)  
Old 03-27-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
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
  #6 (permalink)  
Old 03-27-2008
mavsman mavsman is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 17
I agree but the existing .ksh calls an Informatica process that references a specific flat file for a source. It doesn't allow a dynamic flat file source name so I have to replace the existing one it reads...
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 10:37 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0