Text qualifier and delimiter problem with LoadData
sjr51
I am trying to load in some data from several text files that were downloaded from an online database. It is a mix of text and numeric data. The format is comma separated and each field is qualified by quotes (""). My problem is that some fields contain commas within the quotes and so Igor skips to the next column during LoadData. Since Igor reads the commas for separation, I can't tell him to ignore commas. Is there a way to specify the quotes as qualifiers. Or should I clean the files before feeding them to Igor.
Extremely simplified example:
HEADER 1
HEADER 2
HEADER 3
HEADER 4
"Wave0","Wave1"
"Quick brown, fox","0"
Loaded with
LoadWave/J/W/A/E=1/K=0/L={4,5,0,0,0}/Q
givesWave0[0]= {"\"Quick brown"}
Wave1[0]= {" fox\""}
Wave1[0]= {" fox\""}
when I ideally need
Wave0[0]= {"Quick brown, fox"}
Wave1[0]= {0}
Wave1[0]= {0}
i.e. correct parsing of commas outside of quotes, and ideally removal of quotes and recognising text and numeric data.
I'm sure this is trivial, but I can't see how to do it. Any help much appreciated.
I have written a procedure that handles it. You can find it at http://www.igorexchange.com/node/6880.
You may want to customize the file for your purposes.
December 14, 2015 at 11:48 am - Permalink
December 14, 2015 at 01:40 pm - Permalink