LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Read csv file with double quotes

Solved!
Go to solution

@Phillip Brooks wrote:

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

 

 



Phillip's solution looks very nice but ,as a Caution; you may need to toggle the Quote boolean on 0x22 ", 0x93  “  or 0x94 if the file is generated by an editor that knows to open and close quotes.  (Got bit myself on that one yesterday)


"Should be" isn't "Is" -Jay
Message 11 of 21
(3,649 Views)

@Jeff Bohrer wrote:

@Phillip Brooks wrote:

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

 

 



Phillip's solution looks very nice but ,as a Caution; you may need to toggle the Quote boolean on 0x22 ", 0x93  “  or 0x94 if the file is generated by an editor that knows to open and close quotes.  (Got bit myself on that one yesterday)


Sounds like a good one for here.

 

http://forums.ni.com/t5/BreakPoint/LabVIEW-Minutiae-that-may-bite-you-someday/td-p/1122234/page/3

Tim
GHSP
Message 12 of 21
(3,647 Views)

This version replaces opening and closing quotes (0x93 and 0x94) with straight quotes before parsing. I also added a string input option for my internal use of this function.

 

 


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 13 of 21
(3,627 Views)

Thanks so much Phil!!!!
-I've been working on this on my own for two days now.  I got my vi to leave the commas inside the quotations, but it was taking over 30 seconds to complete!

Rather than try to further troubleshoot and waste time, I decided to google the issue.  Luckily I came across your post!

This really makes my day, Thanks!!!!

Message 14 of 21
(3,139 Views)

Does anyone have a VI that converts an array to strings to a CSV format as well? Of course with the same requirements as above.

0 Kudos
Message 15 of 21
(2,956 Views)

I'm not quite sure what you're looking for here. You want an array to be converted to a string, and then written to a CSV? Or an array of strings to be written to CSV?

 

Nick B.

Applications Engineer

National Instruments

0 Kudos
Message 16 of 21
(2,933 Views)

I'm sorry. That was not worded correctly.

 

PhillipBrooks' VI takes a CSV String as input and outputs a 2D Array of Strings. I was also looking for a VI that takes a 2D Array of Strings as input and outputs a CSV String.

 

Turns out this has been implemented here. This says it follows RFC-4180 which the Wikipedia article mentioned in the first post of this thread refers to.

Message 17 of 21
(2,663 Views)

You do realize this tread has not had a reply in almost two year?

 

There is no difference between string array and CSV. They are both text file. CSV only tell the software you are using how to interpret the data. You should be able to save an array of stings to a file with a CSV extension using LabVIEW very easily. That is standard stuff int he file palette.

 

 

Tim
GHSP
0 Kudos
Message 18 of 21
(2,658 Views)
Solution
Accepted by JÞB

Just to put closure on this thread

 

 

Prior to 2015, the function "Join Strings.vi" was a hidden gem in vi.lib found underneath the advanced strings folder.

 

@ 2015 the function of Array to Spreadsheet String  changed. And really does the same thing right.

 

2019 has native string pallet items that implement string array to delimited string and delimited string to string array. 

 

How much easier do you want it to be?


"Should be" isn't "Is" -Jay
Message 19 of 21
(2,624 Views)

@JÞB I tested both Array to Spreadsheet String (in LV 2018) and String array to delimited string and they both do NOT handle the delimiter in a cell which I think is the point of this thread. This is demonstrated by the attached VIs.

Download All
0 Kudos
Message 20 of 21
(2,596 Views)