awk -F"," '{OFS=","; $1=system("date -d "$1" +%d-%m-%Y") ; print $0}' data.csv | head
I am trying to take the first column of a csv file and standardize the date format to %dd-%mm-%yyyy.
When I try the code above I get date: write error: Broken pipe.
But when I try the code below:
dd=$(csvcut -c 1 -e ISO-8859-1 -d "," data.csv | head -2 | sed -n 2p)
echo $dd
echo $(date -d $dd "+%d-%m-%Y")
I get the the output:
2017-02-03
03-02-2017
What am I doing wrong. Any hints? Thanks.
My system: Ubuntu 16.04.1 LTS
EDIT 2: Here is a sample file: http://grn.dk/sites/default/files/attachments/data.csv
EDIT:
sure CSV data file (input): data.csv (with many rows)
Bogført,Tekst,Beløb,Saldo
2017-02-03, random text,-425,-611524.54
output:
Bogført,Tekst,Beløb,Saldo
03-02-2017, random text,-425,-611524.54
but the date format can be in any other format. I am currently looking into standardizing dates for an csv import job. Thanks.