LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   CSV file output reformat (https://www.linuxquestions.org/questions/programming-9/csv-file-output-reformat-4175663044/)

jaybiano 10-23-2019 01:33 PM

CSV file output reformat
 
This is what the CSV look like

Account number (preferred / formatted),Customer reference,Posting date,Account currency,Transaction amount
750856653,233413,3/9/2019,USD,-1439.58
750856653,233431,3/9/2019,USD,-186.66
750856653,NONREF,3/9/2019,USD,14401.48

This is my desired output:

750-85665-3 0000233420 090319000000209299
750-85665-3 0000233417 090319000000285615
750-85665-3 0000233426 090319000000239225


MY CODE: (i am confused please help)
#!/bin/bash

input="/file-path/details.csv"
column -t -s: |
sed 's/ ,/,/g'
while IFS=',' read -r f1 f2 f3 f4 f5
do
echo "$f1 $f2 $f3 $f4 $f5 "
done < "$input"

astrogeek 10-23-2019 01:39 PM

Please post your thread in only one forum. Posting a single thread in the most relevant forum will make it easier for members to help you and will keep the discussion in one place. This thread is being closed because it is a duplicate.


All times are GMT -5. The time now is 01:28 AM.