09-27-2012 03:08 PM
Ok,
I am having issue with keeping the formatting of CSV files. Traditionally, I have uses TXT file formats to keep track of everything from data to calibration curves. I use tab delimiter in over 10 or so years of doing this I have never had any issues.
Fast forward to now, I was in a bind and out sourced some work to a contractor. Even though I gave them a specific style guide, they did a lot of things their own way i.e. CSV vs TXT. Since the project was much more than just LabVIEW code I couldn't really reject the work.
The problem is that customers are opening the CSV files in numerous programs (Notepad, Wordpad, Excel, OpenOffice, etc.). I am finding that some programs insert quotes around row data. By example a specfic row should look like this:
pH Slope,10
pH Intercept,-15
Instead it look like this:
"pH Slope,10"
"pH Intercept,-15"
When I search the file for pH Slope I don't find it.
In addition to that, sometimes additional rows are added all together and look like this:
"pH Slope,10"
,
"pH Intercept,-15"
I will use a Search and Replace subVI to remove all the " and remove them. But what is the best way to elimate this type of things from happening all together?
09-27-2012 05:36 PM
The best way is to reject the work and tell them to give you what they were contracted to give you. Excel will take liberties with a file that has a CSV extension. Writing a VI to remove the quotes is kludgy but it will work as long as you never expect quotes to be contained in valid data.
09-27-2012 05:49 PM
Based on what you are describing, I expect your customers are opening the files in a spreadsheet program, but are not using a comma as a delimiter. So, if they re-save the file, the spreadhseet is putting quotes around the text blocks.
At this point, as you said, you will probably need to remove the quotes and blank lines (that I have no insight on).
If your customer are modifying/saving these files, either tell them to import them correctly, or not to use anything but a text editor.
09-29-2012 08:22 AM