Hi,
Please help me on this.
I want to insert data from text file to excel using shell script
nawk -v r=4 -v c=4 -v val=$a -F, 'BEGIN{OFS=","}; NR != r; NR == r {$c = val; print}' "file.csv"
I used above one to insert $a value in 4th row, 4th column in an excel file.csv and it worked.
Now my problem is, i have a data like below...
/u1
/u2
/u3
I want to insert all 3 lines in a single cell i.e., 4th row, 5th column using shell/awk script.
Please help me.
Thanks,
I'm not sure CSV can accommodate this, CSV is one line per row.
zoite
3
How about something like the following?
input_file.txt
/u1
/u2
/u3
#!/bin/bash
while read line; do
row+=$(echo "$line" | tr '\n' ' ')
done < input_file.txt
nawk -v r=4 -v c=5 -v val="$row" -F, 'BEGIN{OFS=","}; NR != r; NR == r {$c = val; print}' "file.csv"
Thanks Zoite,
It worked...
but instead of row+=$(echo "$line" | tr '\n' ' ')
i wrote row="$row $line"
Problem solved, Thanks for the solution.