LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Read csv file with double quotes

Solved!
Go to solution

I would like to be able to read comma separated files (.csv) into LabView. The code implementation must follow all the rules for .csv files.

 

Please see basic rules here if unsure what I mean.. http://en.wikipedia.org/wiki/Comma-separated_values

 

Does anyone have any working, good code to share?

 

Thanks,

Patrik

0 Kudos
Message 1 of 21
(7,957 Views)

When you tried the Read From Spreadsheet File with a comma as the specified delimiter, what problems did you have?

0 Kudos
Message 2 of 21
(7,953 Views)

Then..

Commas inside double quotes are not treated correctly when doing so. Commas inside double quotes should be kept and not be treated as separators. Another problem is that line brakes inside double quotes should be treated as a line brake within the same column and not a line break for the whole table. Furthermore, most double quotes should be removed but some should be kept. Please see the link that I provided for the details..

 

It surprises me that this is not a native LabView VI already.

 

Thanks,

mrsound

0 Kudos
Message 3 of 21
(7,943 Views)
0 Kudos
Message 4 of 21
(7,928 Views)

Okay, now I understand what you are looking for.

 

No, the function depends on the Spreadsheet String to Array which does not support a " as an escape character. This function was written long before the mentioned CSV "standard". I've never seen any request for this functionality but you can submit it to the Idea Exchange.

 

Darin - thanks for the link. My search came up blank.

0 Kudos
Message 5 of 21
(7,927 Views)

It sounds like you are going to have to do some custome work. You are going to have to open it as a string an then post process it to achieve what you are looking to do.

Tim
GHSP
0 Kudos
Message 6 of 21
(7,926 Views)

 


@Darin.K wrote:

Something eerily similar....

 

http://forums.ni.com/t5/LabVIEW/csv-with-double-quotes/m-p/1098279#M485663


Yes, but the double quotes are still there and it doesn't work for line brakes within the same cell.

 

0 Kudos
Message 7 of 21
(7,915 Views)

 


@aeastet wrote:

It sounds like you are going to have to do some custome work. You are going to have to open it as a string an then post process it to achieve what you are looking to do.


I was hopeing it was already implemented so that I could save myself some work..

 

0 Kudos
Message 8 of 21
(7,900 Views)

I recently needed to parse a CSV that contained quotes and line breaks within a field. Here is my solution (LV 8.0)...

 

 


Now is the right time to use %^<%Y-%m-%dT%H:%M:%S%3uZ>T
If you don't hate time zones, you're not a real programmer.

"You are what you don't automate"
Inplaceness is synonymous with insidiousness

Message 9 of 21
(7,597 Views)

Thank you! 🙂

0 Kudos
Message 10 of 21
(7,563 Views)