LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to write on a spreadsheet

Solved!
Go to solution

I want to write the data displayed in LabVIEW into a spreadsheet.
However, I could not save the data due to an error.
I want to save the data written to the spreadsheet as a csv file.

 

Below is the error message.
-----------------------------------------------------------------
LabVIEW (Hex0×7)
File not found. The file may be in a different location or may have been deleted. Use a command prompt or file explorer to verify that the path is correct.
-----------------------------------------------------------------


Attached is the program for the relevant area.

csv保存.png

 

0 Kudos
Message 1 of 7
(247 Views)
Solution
Accepted by topic author ikeda_kaoru

Nobody in his right mind will touch your code, but let's focus on the spreadsheet write.

 

You open and close a file, but you never wire a path to the file write function.

You should also NEVER operate on entire paths as string

Format date/time assumes current time, no need to wire a timestamp

The way you process the time string is dangerous, because it trims leading zeroes from the month. This makes it ambiguous for many dates.

 

Here's a working alternative

 

altenbach_0-1749709996563.png

 

0 Kudos
Message 2 of 7
(224 Views)

Hi ikeda,

 


@ikeda_kaoru wrote:

LabVIEW (Hex0×7)
File not found. The file may be in a different location or may have been deleted. Use a command prompt or file explorer to verify that the path is correct.


In addition to Christians comment:

The default operation mode of the FileOpen function is to (just) "open" a file. There are other modes like "Create or open" when you want to create a file on first file access…

(Or to put it short: read the help for each function you use! 😄 )

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 7
(183 Views)

If yo look inside "write delimited spreadsheet" (yes, it is just a plain VI where you can look at the code!), you can see that it already does various tests and opens/cluses the file. All it needs is a path! In your case it should have given a file dialog popup, which you should have seen.

 

However, Gerd's point is important, because your VI uses "file open" quite excessively in other parts (there are 10(!!!) instances scattered all over that gigantic diagram!!) and some seem to have unicode(?) file names hardwired. All file names seems to be base on time and thus always new.

 

This program is such a hairball that it should be tossed and rewritten as a simple state machine that fits on one screen. There is no way to reasonably debug this, because I can only see <10% of the code at any given time. Here's how the navigation window looks like! There is way too much convoluted and duplicate code! There is a lot of code smell!

 

 

 

altenbach_0-1749736985459.png

 

0 Kudos
Message 4 of 7
(163 Views)

@altenbach さんは書きました:

Nobody in his right mind will touch your code, but let's focus on the spreadsheet write.

 

You open and close a file, but you never wire a path to the file write function.

You should also NEVER operate on entire paths as string

Format date/time assumes current time, no need to wire a timestamp

The way you process the time string is dangerous, because it trims leading zeroes from the month. This makes it ambiguous for many dates.

 

Here's a working alternative

 

altenbach_0-1749709996563.png

 


Thank you for your reply.

 

I was able to modify the program you attached and save the CSV file.
The data in the file was also correct.

 

Thank you very much.

0 Kudos
Message 5 of 7
(87 Views)

Hi GerdW,

 


@GerdW さんは書きました:

Hi ikeda,

 


@ikeda_kaoru wrote:

LabVIEW (Hex0×7)
File not found. The file may be in a different location or may have been deleted. Use a command prompt or file explorer to verify that the path is correct.


In addition to Christians comment:

The default operation mode of the FileOpen function is to (just) "open" a file. There are other modes like "Create or open" when you want to create a file on first file access…

(Or to put it short: read the help for each function you use! 😄 )

 

I used your help and advice and modified the program and the save worked.
Thank you very much!

 

Best regards,
ikeda

 


 

0 Kudos
Message 6 of 7
(82 Views)

@altenbach さんは書きました:

If yo look inside "write delimited spreadsheet" (yes, it is just a plain VI where you can look at the code!), you can see that it already does various tests and opens/cluses the file. All it needs is a path! In your case it should have given a file dialog popup, which you should have seen.

 

However, Gerd's point is important, because your VI uses "file open" quite excessively in other parts (there are 10(!!!) instances scattered all over that gigantic diagram!!) and some seem to have unicode(?) file names hardwired. All file names seems to be base on time and thus always new.

 

This program is such a hairball that it should be tossed and rewritten as a simple state machine that fits on one screen. There is no way to reasonably debug this, because I can only see <10% of the code at any given time. Here's how the navigation window looks like! There is way too much convoluted and duplicate code! There is a lot of code smell!

 

 

 

altenbach_0-1749736985459.png

 


Thank you for your reply.

 

I apologize for the complexity of the program, which is difficult to see.

I will try to think of a way to make the program simple enough to fit on one screen, so that the complicated parts can be summarized.

 

Thank you very much.

Message 7 of 7
(77 Views)