LQ Newbie
Registered: Oct 2019
Location: New York
Posts: 9
Rep:
|
creating a script that would read in a csv file and output the data in a different format to load into the Lawson payroll system
- this involves creating a Linux script that be run to read in a csv file and output the data in a different format to load into the Lawson payroll system
- the script will be run automatically by skybot whenever an input file is created in a Linux folder.
This is what the CSV look like
Account number (preferred / formatted),Customer reference,Posting date,Account currency,Transaction amount
750856653,233420,3/9/2019,USD,-2092.99
750856653,233417,3/9/2019,USD,-2856.15
750856653,233413,3/9/2019,USD,-1439.58
750856653,233431,3/9/2019,USD,-186.66
750856653,NONREF,3/9/2019,USD,14401.48
750856653,233430,4/9/2019,USD,-320.93
750856653,233427,4/9/2019,USD,-661.9
750856653,233412,4/9/2019,USD,-1888.92
750856653,233428,4/9/2019,USD,-245.71
This is my desired output, i want the account number separated with a hyphen just like that, i want 3 zeros added in front of the customer reference and lastly, the date and transaction amount should be merged to be one. with zeros . Eliminated the USD, initially i had 5 columns, my final result should be just 3 columns.
750-85665-3 0000233420 090319000000209299
750-85665-3 0000233417 090319000000285615
750-85665-3 0000233426 090319000000239225
750-85665-3 0000233414 090319000000173322
750-85665-3 0000233424 090319000000185031
750-85665-3 0000233403 090319000000185032
750-85665-3 0000233413 090319000000143958
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"
|