LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Create Column Headers and Filename for Write Delimited Spreadsheet

Solved!
Go to solution

Hi,

I am writing data from multiple sensors with Write Delimited Spreadsheet VI. I know how to create headers for each column of data using an array of Strings sent to a separate instance of Write Delimited Spreadsheet and passing that to the original Write Delimited Spreadsheet, but I want to be able to specify the actual filename automatically. Since the column headers are already passed to the File Path input, I'm not sure how to specify both the Headers and the Filename at the same time. (I'm assuming one would normally create the file name by appending the name as a string to the end of the desired file path then passing the resulting string to the File Path input.)

Thanks.

0 Kudos
Message 1 of 8
(485 Views)

Hi mdc,

 


@mdc0047 wrote:

(I'm assuming one would normally create the file name by appending the name as a string to the end of the desired file path then passing the resulting string to the File Path input.)


There is a BuildPath function. And there are string functions to create strings as you like, and they can be used to create a filename…

 


@mdc0047 wrote:

Since the column headers are already passed to the File Path input, I'm not sure how to specify both the Headers and the Filename at the same time.


This doesn't make any sense to me.

You can wire a filepath and array data to the WriteDelimitedSpreadsheet function…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 8
(467 Views)

Please attach the VI in LV2020 or older version (File->Save for previous)

 

I recommend trying the CSV Logger from SLL Toolkit

 

Here is an example from the toolkit

santo_13_1-1728931176522.png

 

 

santo_13_0-1728931168679.png

 

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 3 of 8
(464 Views)

The tutorials I have so far found online directed me to create an array of Strings that contains all column headers (I'll be outputting long columns of doubles). This array is sent to a separate Write Delimited Spreadsheet VI. This is then passed to the File Path input of the original Write Delimited Spreadsheet VI, causing the array of Strings to be added to the resulting output file as headers. However, if this File Path input is already occupied by headers, I cannot also add a string constant to specify File Path to this input.

Basically, I understand how to add headers to the data OR specify a file path with a file name, but since both of these operations make use of the File Path input node, I don't know how to do BOTH at the same time.

 

(for reference, I'm basing this off of the following tutorial at timestamp about 19:30

https://www.youtube.com/watch?v=fIy6XT3CdPQ )

 

Thanks for your help.

0 Kudos
Message 4 of 8
(446 Views)

Thanks for your help. I am looking for something a little less dependent on user input since I will saving so much data. This VI should now be 2020.

0 Kudos
Message 5 of 8
(442 Views)

You're confused- you do not put the headers in the file path (that makes no sense). If the File Path input has header strings... how does LabVIEW know which file to write to?

 

The reason you call the function twice is that the first time you write to a file with some strings, the second time you write to the SAME file with data. You have to have "Append" set to True to append the data.

 

BertMcMahan_0-1728933576522.png

 

You can prove this to yourself by deleting the second "Write to Spreadsheet" function and opening the file. It'll just have some headers.

Message 6 of 8
(435 Views)
Solution
Accepted by topic author mdc0047

Just saw you posted your code after I wrote my last post. Wire in your desired filename here:

 

BertMcMahan_0-1728933719524.png

If you do that, there won't be a popup for the user to select a location.

 

If you review the Detailed Help for Write to Delimited Spreadsheet, you will see the following:

 

BertMcMahan_1-1728933786576.png

 

 

It's opening a popup for the user to select a path since the "file path" input is blank. I know you think you're wiring in the headers to the file path input, but you're not. You wire those to the "1D Data" input.

Message 7 of 8
(430 Views)

Thank you! That works perfectly.

0 Kudos
Message 8 of 8
(425 Views)