![]() |
|
|
|||||||
| Home | Forums | Register | Rules & FAQ | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. Shell Script Page. |
Other UNIX.COM Threads You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| What's wrong with this line: if ${TEST:?} ; then echo empty; fi | meili100 | UNIX for Dummies Questions & Answers | 2 | 02-23-2008 07:45 AM |
| checking for empty string in tcsh | pagod | Shell Programming and Scripting | 3 | 12-07-2007 01:22 AM |
| checking size of the first line in a log file | kiran1112 | Shell Programming and Scripting | 19 | 03-22-2007 10:46 AM |
| empty line | YoYo | Shell Programming and Scripting | 4 | 09-21-2005 08:14 PM |
| printing an empty line in a file (perl) | kfad | Shell Programming and Scripting | 3 | 05-07-2005 12:10 AM |
![]() |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
Checking the Empty line in csv file
Hi all,
I have one CSV file(MasterFile.csv) consists of two columns. "./incoming/ABC.CSV","./incoming/ABC_CONTROL.txt" "./incoming/PQR.CSV","./incoming/PQR_CONTROL.txt" "./incoming/123.CSV","./incoming/123_CONTROL.txt" I have written a script to read the MasterFile.csv.Here i want to check the Empty line entry and try to ignore during the script execution... My script code snippet is follow writeToLog "=====New Logs for data file validation=====" writeToLog "===========================================" validateScript="./validateFile.sh" masterFile="./MasterFile.csv" if [ ! -f $masterFile -o ! -r $masterFile ]; then #exit for now, it will check again when the next cron job runs writeToLog "In Script $0: file $masterFile not found/readable" exit 0 fi if [ ! -f $validateScript -o ! -r $validateScript ]; then #exit for now, it will check again when the next cron job runs writeToLog "In Script $0: script $validateScript not found/readable" exit 0 fi writeToLog "In Script $0: Going to validate all data files listed in the master file - $masterFile" count=0 while [ 1 ] do #execute the following block from the 2nd line onwards, which means skip the header row of the csv file read entryLine || break writeToLog "In Script $0: entryLine=$entryLine" if [ $count -gt 0 ]; then #index of the delimiter that separates the data file and control file names index=`echo $entryLine | awk '{ print index($1,",") }'` writeToLog "In Script $0: index of delimiter = $index" #need to take the substring before the comma index=`expr $index - 1` #echo $entryLine | awk '{ print substr($1, 0, '$index') }' dataFile=`echo $entryLine | awk '{ print substr($1, 0, '$index') }'` writeToLog "In Script $0: current data file = $dataFile" index=`expr $index + 2` controlFile=`echo $entryLine | awk '{ print substr($1, '$index') }'` writeToLog "In Script $0: current control file = $controlFile" #invoke script - $validateScript sh $validateScript $dataFile $controlFile fi count=`expr $count + 1` #echo "count = $count" done < $masterFile writeToLog "In Script $0: Finished validation of all data files listed in the master file - $masterFile" exit 0 PFA contains the required files.. Cheers Soll |
| Forum Sponsor | ||
|
|
|
|||
|
writeToLog "In Script $0: Going to validate all data files listed in the master file - $masterFile"
count=0 while [ 1 ] do Quote:
read entryLine || break writeToLog "In Script $0: entryLine=$entryLine" if [ $count -gt 0 ]; then |