![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | 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 and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| string manipulating | psalas | UNIX for Dummies Questions & Answers | 9 | 04-15-2008 10:00 AM |
| Manipulating File | rivendell500 | SUN Solaris | 2 | 03-25-2008 10:52 PM |
| Manipulating two files | rinku11 | UNIX for Advanced & Expert Users | 4 | 12-11-2006 03:47 AM |
| Manipulating awk $variables using sed? | r0sc0 | Shell Programming and Scripting | 2 | 04-04-2006 06:53 PM |
| date manipulating | tamer | UNIX for Dummies Questions & Answers | 3 | 01-08-2001 09:46 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
manipulating csv to add extra row
hi
how do i manipulate .csv file to add an extra row after each row using shell script? I need a blank line added for each 1000 records in my file? I will then need to copy and paste some data in the blank row created. thanks 4 ur support neil |
|
||||
|
Code:
#!/bin/ksh
cntLoop=1
INP_CSV_FILE=$1
OUT_CSV_FILE="$HOME/outfile.csv"
rm -f $OUT_CSV_FILE
for line in `cat $INP_CSV_FILE`
do
echo $line >> $OUT_CSV_FILE
echo "Test,Your row here" >> $OUT_CSV_FILE # Addition of a row after each row in CSV
if [[ $cntLoop -eq 500 ]] # Addition of a blank line after 1000 records of the output
then
echo >> $OUT_CSV_FILE
cntLoop=0
fi
cntLoop=$((cntLoop+1))
done
Code:
ksh compute_csv.ksh infile |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|