09-19-2023 08:09 PM - edited 09-19-2023 08:09 PM
When use Write Delimited Spreadsheet VI to save table(the datatype is string) to .xls or .csv file, the saved data lost 0 in the end of decimals.
For example:
The content in the table(the datatype is string): 1.2000
The content in the saved file (.xls or csv): 1.2
I want to keep the value same! The content in the saved file (.xls or csv) should be 1.2000, how to solve it?
09-19-2023 08:59 PM - edited 09-19-2023 09:01 PM
Question, why does the trailing zeroes matter for numeric data?
1.2 == 1.20000
You can specify the format specifier to retain certain number of digits
Though you save 1.2000 in the file, when you open in Excel, Excel always optimizes to show the simpler representation. On the other hand, if you open the same file in text editor like notepad you will still see it as 1.2000 but Excel may not show 1.2000
09-19-2023 09:13 PM
Reply to "Question, why does the trailing zeroes matter for numeric data?"
For us, keep the value consistent is necessary. If the zeros has been removed, we should add an axtra step to prove the data is consistent and reliable. And according to the precision requirement, the precision of 1.2000 is 0.0001, but the precision of 1.2 is 0.1.
09-19-2023 09:34 PM
@Sandra421 wrote:
Reply to "Question, why does the trailing zeroes matter for numeric data?"
For us, keep the value consistent is necessary. If the zeros has been removed, we should add an axtra step to prove the data is consistent and reliable. And according to the precision requirement, the precision of 1.2000 is 0.0001, but the precision of 1.2 is 0.1.
Okay, if that is a requirement for consistency, you can specify the format specifier to write the numeric data with required digits of precision.
09-20-2023 07:55 AM
You don't need to "solve it".
If you run this Test VI (which I named "WDS Test.vi"), it will produce a Text file with the following contents: 1.2 1.20 1.200 1.2000 1.20000 1.200000.
If you give it an extension of .csv, and then open it with a program "linked" to .csv files, then the program you use to open it might ignore the trailing zeros ...
Bob Schor
09-20-2023 11:58 AM
@Sandra421 wrote:
I want to keep the value same! The content in the saved file (.xls or csv) should be 1.2000, how to solve it?
The "values" ARE the same, they just differ in formatting:
You are dealing with two completely different issues:
What problem are you trying to actually solve? Once you define it we can give specific advice! 😄
09-20-2023 08:07 PM
If you take the little demo that I wrote and change the name of the output files so that its extension is .csv, or .xlsx, instead of .txt, and then look at the bytes in the file, they will be byte-for-byte identical. The problem isn't LabVIEW's -- it always write strings as strings, no matter the extension. On the other hand, non-LabVIEW routines (such as Microsoft's Excel) may change how they represent the different strings. A text routine, however, can be expected (or "hoped-for") to simply echo the byte values that you have presented.
And that's my $0.02000000000 (or two cents) on that. "The fault, dear Brutus , is not in our stars, But in ourselves, that we are underlings." So do the experiment, don't necessarily believe me, and definitely don't let M$ products "confuse" you.
Bob Schor