I have a CSV file having data containing comma (,) in it.
So whe i read the file as the data contain(,) the data is read as two different value.
Can anyone suggest any idea or is there ay VI available to overcome this problem of having (,) as data for CSV file.
Give a try using spread sheet string to array function and making delimeter as ,(comma). I think it will work out..
By definition, a CSV file has data separated by commas. That means you can't have commas in your data. Some implementations (Excel, for instance) allow you to have commas in your data if you wrap the data in double quotes (so 1,2,"3,4",5 will result in 4 columns) or escape it, but LV doesn't recognize that. You can see some more here - http://en.wikipedia.org/wiki/Comma-separated_values
The easiest thing to do is to use another delimiter and not call the file CSV. If you want to fix the existing file, you can probably open it in Notepad, put quotes around the relevant data, then open it in Excel and replace the commas with another character.
Are your "CSV" file data stored with a fixed number of bytes per field? Can you look at the file and *know* that the comma is data and not a delimiter? If you can know it, you can write a program to figure it out. Perhaps you can show us some sample data and explain why a particular comma isn't a delimiter and we can help.
I am having the same issue. I have a CSV file that is comma delimited. One of data columns has value which contains a comma, but this data is wrapped in double quotes. I am using the Read Delimited Spreadsheet VI to parse the CSV data. However LabVIEW 2017 doesn't properly read the data because the value contains a comma, but this value is wrapped in double quotes.
Is there a solution to this issue without having having to the change the delimiter of the CSV file?
The only thing I can think of is to "pre-process" your data by reading the text and using "search and replace" in a judicious manner. Then use the "Spreadsheet String to Array" function to parse it all out.
Depending on how well formatted the file is, it can work with ", " (comma, space) as delimiter.
Great Zombie Discussion, i.e. broughT back from the DEAD. lol.
It's a crying shame there isn't an input on the read delimited spreadsheet string VI that accounts for numbers with commas that are surrounded by double quotes.
Saving XLS files to .txt, or tab delimited, is truly the way to go.
I do like the idea of using [ "," ] as the separator, or even [ ," ] followed by a replace double quotes with nothing approach. But, as said ... the data has to be well behaved.
I guess it only comes as a problem when the data file is not 're-savable' from csv format to tab delimited format.
Would love to chase this down but have bigger fish to fry, so to speak, at the moment.
As long as it's well behaved there's really no problem, but if it's less so, e.g. a different amount of spaces, you'll have to use some cleaning. E.g. a regular expression search of \"(^\")+\" (if I managed to format that correctly, regular expressions is the closest thing to magic I know. ^^