LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Strings sent to .csv file are modified

Solved!
Go to solution

When I send a string array to a .csv file the strings are modified. Example: The string 29,000 is changed to 29. I'm not sure if this is a LabVIEW or Excel problem. I've attached Test.vi.

0 Kudos
Message 1 of 12
(2,538 Views)

The strings aren't modified - open the file in notepad and you will see the file is as you wrote it - 10.000E-6,29,000. But, when you try and open it in Excel, if you tell Excel it's a comma separated variable file, it assumes the '29,000' is two variables. So, dont use strings with nested comma's in a CSV file, or use some other character as a delimiter. 

0 Kudos
Message 2 of 12
(2,526 Views)

Thanks. I see that now, but my other string 10.000E-6 is changed to 1.00E-05. 

0 Kudos
Message 3 of 12
(2,516 Views)

Hi MPerlick,

 

The 29 is coming out weird because you have placed a comma within that string and used comma as the delimiter which causes the write VI to parse that number into two numbers, which is why you also see a 0 in the cell next to 29. That's the ",000" portion of the string which has been parsed into a separate cell. All you need to do is remove the comma from the number or use a different delimiter.

 

 

Regards,
0 Kudos
Message 4 of 12
(2,514 Views)

@MPerlick wrote:

Thanks. I see that now, but my other string 10.000E-6 is changed to 1.00E-05. 


Same number, different representation - again, the original string is maintained if you open the file in notepad. Its an excel setting to display it as 1.00E-05 verses 10.000E-6.

0 Kudos
Message 5 of 12
(2,508 Views)

Thanks DJColeslaw:

 

I did remove the comma, but I'm still having an issue with the string 10.000E-6. It's coming out as 1.00E-05. This should be a string.

0 Kudos
Message 6 of 12
(2,507 Views)

@MPerlick wrote:

Thanks DJColeslaw:

 

I did remove the comma, but I'm still having an issue with the string 10.000E-6. It's coming out as 1.00E-05. This should be a string.


That is the same number. It just moved the decimal point.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 7 of 12
(2,501 Views)

I suspect the change in formatting is due to Excel. If you select a column, right-click, and go to "format cells" you have quite a bit of flexibility in setting how Excel formats the data it interprets. Less feature-rich text editors that don't auto-format the text won't have this problem.

Regards,
0 Kudos
Message 8 of 12
(2,496 Views)
Solution
Accepted by topic author MPerlick

@DJColeslaw wrote:

I suspect the change in formatting is due to Excel. If you select a column, right-click, and go to "format cells" you have quite a bit of flexibility in setting how Excel formats the data it interprets. Less feature-rich text editors that don't auto-format the text won't have this problem.


It is - if instead of saving the file as a csv file, you save it as a text file, when you then try and open it in Excel it will take you through an import wizard that will allow you to specify the format of the data. 

0 Kudos
Message 9 of 12
(2,489 Views)

Thanks again. I see my data is saved as Scientific. I'll try your suggestion and save it as a text and then try to open it in excel and use the import wizard. I wouldn't be so picky, but this is the test results data for the customer.

0 Kudos
Message 10 of 12
(2,468 Views)