[Thread Prev][Thread Next][Index]

Re: [ferret_users] csv header and quotes



Hi Marco,

> I am writing a generic CSV file reading script, which takes the header
> of the file to interpret this as the variable names.  Often there are
> spaces and units between brackets in these headers, such as (test.csv):
> 
> v1,v2 (m),v3[nM], v4(nM)
> 12,123456,123456, 4
> 12,123456,123456, 8
> 
> let my_columns={spawn:"head -1 test.csv | sed 's/\[[^][]*\]//g' | sed 's/([^()]*)//g' | sed 's/\ //g'"}
> columns/var="`my_columns`"/skip=1 test.csv

Your code works on my Ferret installation (FERRET v6.81, Linux
2.6.32-279.1.1.el6.x86_64 32-bit - 07/23/12, 6-Nov-12 08:59).
I don't see the double quote in my_columns .

> So it takes the first line of test.csv, removes two types of brackets
> and the text in between and removes the spaces.  This is put in
> variable my_columns, but this does not work.  When I do a (more simple
> than the columns command) a say, I get:
> 
> yes? say "`my_columns`"
> "!-> MESSAGE/CONTINUE "v1,v2,v3,v4
> 
> The quotes are misplaced.  What do I do wrong?

Might your CSV file contain the double quote you get?
I mean, in some CSV implementations, character
strings are enclosed in double quotes when they
contain special characters.

Ryo


[Thread Prev][Thread Next][Index]
Contact Us
Dept of Commerce / NOAA / OAR / PMEL / Ferret

Privacy Policy | Disclaimer | Accessibility Statement