[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] Bash read specific element from csv

From: lxnf98mm
Subject: Re: [Help-bash] Bash read specific element from csv
Date: Tue, 7 Oct 2014 09:09:43 -0500 (CDT)
User-agent: Alpine 2.11 (LRH 23 2013-08-11)

On Tue, 7 Oct 2014, Phil wrote:


I am struggling to find the bash code to read a specific element from a CSV. The csv is constructed as follows:
<--------- SNAP --------->
"Naam";"ISIN";"Symbol";"Market";"Trading Currency";"Open";"Hoog";"Laag";"Last";"Last Date/Time";"Time Zone";"Volume";"Turnover"
"European Equities";"";;;;;;;;;;;
"28 Sep 2014";;;;;;;;;;;;
"All datapoints provided as of end of last active trading day.";;;;;;;;;;;;
"IDI";"FR0000051393";"IDIP";"Euronext Paris";"EUR";"23.42";"23.50";"23.42";"23.42";"26/09/2014 12:00";"CET";"21";"492.98" "BETER BED";"NL0000339703";"BBED";"Euronext Amsterdam";"EUR";"16.80";"16.80";"16.48";"16.645";"26/09/2014 17:35";"CET";"1206";"20106.64" "ALCATEL-LUCENT";"FR0000130007";"ALU";"Euronext Paris";"EUR";"2.494";"2.504";"2.446";"2.486";"26/09/2014 17:39";"CET";"15581702";"38683091.21" "FIPP";"FR0000038184";"FIPP";"Euronext Paris";"EUR";"0.08";"0.08";"0.08";"0.08";"26/09/2014 10:35";"CET";"20001";"1600.08" "ROBERTET CI";"FR0000045601";"CBE";"Euronext Paris";"EUR";"101.70";"101.70";"101.70";"101.70";"23/09/2014 12:00";"CET";"40";"4068.00"
<--------- SNAP --------->

I want bash to read the first element on the third line, containing the date (ie 28 Sep 2014), and return into a string.

The closest I get is
 sed -n "3 p" myFile.csv
"28 Sep 2014";;;;;;;;;;;;

I thought that awk would help me out, but the following command give me only:
 sed -n "3 p" EU.csv | awk '{print $1}'

sed -rne 's/^"(.*)";+$/\1/p' myFile.csv

reply via email to

[Prev in Thread] Current Thread [Next in Thread]