On Tue, Oct 07, 2014 at 08:03:44PM +0200, Phil wrote:
The objective is simply for filenaming purposes. The file of which a
snapshot is given underneath comes in everyday. When the file is
received it is always called Euronext.csv. The objective is simply to
read the data stamp in the third row first column (28 Sep 2014), and
rename the file from Euronext.csv to Euronext 28 Sep 2014.csv or even
better Euronext 20140928.csv
OK. I was afraid you would go on to say something like "And then I
need to read each line after that, and extract the Hoog field, ..."
<--------- SNAP --------->
"Naam";"ISIN";"Symbol";"Market";"Trading
Currency";"Open";"Hoog";"Laag";"Last";"Last Date/Time";"Time
Zone";"Volume";"Turnover"
"European Equities";"";;;;;;;;;;;
"28 Sep 2014";;;;;;;;;;;;
The only semi-difficult thing at this point is converting Sep to 09.
That can be done with an associative array in Bash 4.
declare -A month
i=1
for m in Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec; do
printf -v "month[$m]" %02d $((i++))
done
{ read; read; IFS=';' read date _; } < Euronext.csv
date=${date//\"/}
read d m y <<< "$date"
filename="Euronext $y${month[$m]}$d.csv"
echo "<$filename>"