LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

External CSV Reader package

Solved!
Go to solution

 

"Read Delimited Spreadsheet" works fine for plain numeric data... but croaks when trying to read string data that is surrounded by quotes containing a comma. For example the CSV file:

Date/Time,Value

"Aug 31, 2:00PM",42

 

would return 3 columns:

 

"Aug 31 | 2:00PM" | 42

 

Quick google hunt didn't find anyone haven written a package to do this. Sure, I can do it myself but I figured I'd take the lazy "maybe someone has already done it" approach first.

0 Kudos
Message 1 of 6
(695 Views)

@BowenM wrote:

 

"Read Delimited Spreadsheet" works fine for plain numeric data... but croaks when trying to read string data that is surrounded by quotes containing a comma. For example the CSV file:

Date/Time,Value

"Aug 31, 2:00PM",42

 

would return 3 columns:

 

"Aug 31 | 2:00PM" | 42

 

Quick google hunt didn't find anyone haven written a package to do this. Sure, I can do it myself but I figured I'd take the lazy "maybe someone has already done it" approach first.


Everything is going to treat a comma as a separator in a file that is supposed to contain Comma Separated Values.

 

You could try setting the separator to " if that's what is actually separating the values in the file.

 

Otherwise post a sample of the data file you are working with maybe we can come up with a more elegant solution.

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 2 of 6
(685 Views)

Yep. CSV stands for Comma Separated Value. Got it.

 

CSV standard allows for string fields to be enclosed in double quotes

 

"Aug 31, 2:00PM"

 

In those cases, every CSV parser in another language (Excel included) reads the comma enclosed in double quotes as part of the string field, not as a separator.

Message 3 of 6
(668 Views)
Solution
Accepted by topic author BowenM
Message 4 of 6
(646 Views)

Hunted VIPM, don't know how I missed it.


Thank you!!

0 Kudos
Message 5 of 6
(625 Views)

@BowenM wrote:

 

In those cases, every CSV parser in another language (Excel included) reads the comma enclosed in double quotes as part of the string field, not as a separator.


Silly me didn't believe Excel was that smart... sure enough, it works as described! 😳

---------------------------------------------
Former Certified LabVIEW Developer (CLD)
Currently using LabVIEW 2022
0 Kudos
Message 6 of 6
(435 Views)