LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

help with write to spreadsheet file

Solved!
Go to solution

Hi everybody,

 

I'm currently trying, after some data gathering, to put everything into a .xls file.

I also need to append DE_testnumber_year (DE-XXXYY) to the file name, so the final file should be someting like DEXXXYY_nameoffile.

 

I tried to realise this in the VI i attached.

 

The drawbacks i encountered are :

 _ the user can't chose where his file will be saved ( i can't get the system directory to appear AND to chose a part of the file name)

 _ The data is gathered in my 1D array but when i open the file created (when i dont put any input in the "path" of Write to Spreadsheet) it is empty

 _ Even when i write a full path directory (which i think is correct) i get an error

 

Do you see what's wrong with this code? Is there another way to do what i'm looking for?

 

Thanks,

Clement Z.

 

PS : sorry for the mess this VI is, it's my testing VI

0 Kudos
Message 1 of 11
(4,347 Views)

Hi Clement,

 

there is a "Save button" event in your event structure, but we miss the subVI in that event…

Attach your subVI and we can talk about your problem!

 

the user can't chose where his file will be saved ( i can't get the system directory to appear AND to chose a part of the file name)

We cannot see your subVI so we cannot comment this item…

 

The data is gathered in my 1D array but when i open the file created (when i dont put any input in the "path" of Write to Spreadsheet) it is empty

Your case structure ahs a "default if unwired" output tunnel, that could cause a lot of trouble…

 

Even when i write a full path directory (which i think is correct) i get an error

Which error  do you get?

 

What's the purpose of all that RubeGoldberg you connected to your "Boolean" button? 😄

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 11
(4,338 Views)

Hi,

 

I attached all the VI concerned this time !

 

Concerning the boolean button, i was trying to find a way to display, on the same indicator, data from two different sources.

 

This is the error i get when i :

 _ reinitialize the values

 _ run the VI

 _ click the GO AUTO button

 _ wait for the graph to be completed

 _ click Save button

 _ agree to name the file

 

forum labview02.png

That might be because i misunderstood the block VI : does it not create a file if the path does not lead to an existing one ?

 

Concerning the 1D array data, i don't get how i could do it differently than using the "default if unwired" mode.

 

Thank you for your concern,

Clement Z.

 

 

PS: i tried using a local variable of my 1D array in the FALSE mode and i'll keep you in touch for the results

PPS: i tried adding .xls in the path string i created but i still get the error

 

 

 

 

Download All
0 Kudos
Message 3 of 11
(4,322 Views)
Solution
Accepted by Orbieu

Hi Clement,

 

Concerning the 1D array data, i don't get how i could do it differently than using the "default if unwired" mode.

Use a shift register - in your outer while loop…

 

That might be because i misunderstood the block VI : does it not create a file if the path does not lead to an existing one ?

You have to ensure the file path exists before you can write a file into that path.

Make sure the folder(s) exist(s)!

 

On your filename creation problem:

check.png

NEVER use strings to build paths! Use path constants and path functions!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 11
(4,314 Views)

Hi,

 

Thank you for your advices i finally got it to work just fine ! See attached VI.

 

There are only a few details that still puzzle me :

 _ my save button is supposedly a latch when pressed mechanical action but when the file is created the color of this button is orange : it is still pressed. Do you know why that is and what i can do to change this ?

 _ when i then want to stop my VI i must click 2 times on the stop button, without exception. And the same issue appears : it remains pressed.

 

It's probably not a big deal and i don't think i will face the same issues on my main VI but i don't like not to know why it happens like this.

 

Thank you for your help so far !

 

Clement Z.

0 Kudos
Message 5 of 11
(4,295 Views)

Hi Orbieu,

 

my save button is supposedly a latch when pressed mechanical action but when the file is created the color of this button is orange : it is still pressed. Do you know why that is and what i can do to change this ?

Yes, I know: you should put the button terminal inside the event case to ensure it gets read, when the event is fired. Lathced buttons return to their original state when they are read!

 

when i then want to stop my VI i must click 2 times on the stop button, without exception. And the same issue appears : it remains pressed.

THINK DATAFLOW!

Two problems:

- your STOP button is read (most probably) when the loop iteration starts. When you press the button it is most likely read with the next iteration…

- You have a event structure in your code which executes based on events. Is your STOP button one of those events?

- If it is one event in the event structure: why don't you read the STOP button INSIDE the event structure?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 11
(4,289 Views)

Hi,

 

Thank you for your explanation, ideed the problem layed on the presence of the buttons in their respective event cases.

Seems legit !

 

If i need to get multiple 1D arrays data in the same file, do i need to use the same block but with the "append file TRUE" for as many arrays as i need to save ? Or is there an easier way ?

By the way, on the file i opened, the data was stacked on a row, can i get it in column ?

 

Thank you,

Clement Z.

0 Kudos
Message 7 of 11
(4,286 Views)

Hi Clement,

 

If i need to get multiple 1D arrays data in the same file, do i need to use the same block but with the "append file TRUE" for as many arrays as i need to save ?

Yes, you could do it that way…

 

Or is there an easier way ?

Yes. It's called "2D array"…

 

By the way, on the file i opened, the data was stacked on a row, can i get it in column ?

Yes. Use a 2D array…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 11
(4,283 Views)

Hi,

 

Maybe i wasn't clear enough : i'm displaying a temperature over time and speed over time data on the same graph (by the way do you know how i can manage to display two Y-axis on the same graph ?).

 

Therefore, i would need to save three 1D array : temperature, speed and time

 

I tried the 2D array and i get, indeed, both my arrays in the file created but they are still displayed on 2 lines, not columns.

Is this a property of the "Write to Spreadsheet file" block ? If it is i couldn't find it by rightclicking on it. Maybe i need a property node ?

 

Thank you,

Clement Z.

0 Kudos
Message 9 of 11
(4,272 Views)

Hi Clement,

 

by the way do you know how i can manage to display two Y-axis on the same graph ?

Yes, I know.

(Right-click the Y axis and choose "Duplicate…"!)

 

I tried the 2D array and i get, indeed, both my arrays in the file created but they are still displayed on 2 lines, not columns.

When your 2D array contains two rows you will get just two rows/columns in your CSV file…

When you want to have 3 columns in your data file you need to write those 3 columns…

 

Is this a property of the "Write to Spreadsheet file" block ?

No. It's an input of that function.

Did you read the help for that function? It explains ALL the input parameters!

RTFM!

 

Maybe i need a property node ?

No.

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 10 of 11
(4,264 Views)