LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Save spreadsheet data

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?

 

0 Kudos
Message 1 of 7
(552 Views)

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

santo_13_0-1695175232866.png

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

 

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 2 of 7
(531 Views)

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.

 

 

 

0 Kudos
Message 3 of 7
(523 Views)

@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.

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 4 of 7
(510 Views)

You don't need to "solve it".  

WDS Test.png

 

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

0 Kudos
Message 5 of 7
(476 Views)

@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:

 

  1. What LabVIEW writes the the .csv or .xls file. (Your are using "write delimited spreadsheet" that has absolutely no idea about excel, of course. Giving it a "fake" xls extension will force the OS to open in using excel and excel is typically smart enough to parse the contents and convert to to excel behind the scene. If you later save it as excel, the actual bytes in the file will be very different and you will no longer be able to read it using e.g. "read delimited spreadsheet", because it is now an excel file.
  2. What you use to look at the file later. If you open it in a dumb display (e.g. notepad), you see character-by-character what data has been written. Have you done that? If you open in in a more advanced application, such as excel, the cell formatting has some reasonable defaults, but if you want to see the numbers differently, you simply need to change the cell formatting. You can pad with as many traiilng zeros you like, even if LabVIEW only wrote "1.2" (i.e. 3 characters: a "1", a decimal points, and a "2"!

What problem are you trying to actually solve? Once you define it we can give specific advice! 😄

 

 

0 Kudos
Message 6 of 7
(459 Views)

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

0 Kudos
Message 7 of 7
(435 Views)