LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Auto-Increment File Name

Hi everyone,

 

I am using the Write to Spreadsheet VI to log around 30 channels of temperature data. I will be running my VI for days at a time, and I would like to be able to start a new log every night at midnight. I would also like the name of the file to be automatically incremented too (ie. Data_001, Data_002, and so on) if possible.

 

Is there a way to do this?

0 Kudos
Message 1 of 10
(6,988 Views)

Something like this will work.  If you're writing to the file frequently, it will be faster to open the file once and keep the file refnum in the shift register instead of the path; you'd need to use "Write to Text File" instead of "Write to Spreadsheet File."

increment file name daily.png

Message 2 of 10
(6,978 Views)

Forgot to add- can't use the Write to Measurement File Express VI because a) I'm making my own headers, and b) I'm setting a custom number format.

0 Kudos
Message 3 of 10
(6,977 Views)

Thanks! I'll try this and see how it works for my application.

0 Kudos
Message 4 of 10
(6,974 Views)

Of course, if you can't wait 24 hours to see how it works, unbundle "hours" or "minutes" instead of "day of month."

0 Kudos
Message 5 of 10
(6,971 Views)

This is a variation on generating the filename. Instead of keeping the value in a shift register you can look at the files that already exist and increment based on that. This is only important if you do not start with an empty directory. The shift register method will start the filename sequence over again the next time you run the VI.

 

Example_VI_BD.png

=====================
LabVIEW 2012


Message 6 of 10
(6,965 Views)

@Steve Chandler wrote:

The shift register method will start the filename sequence over again the next time you run the VI. 



I hadn't thought of that! It seems that Steve's example is what I need but is there a way to get his code to auto-increment once per day without using shift registers? Ie. a more absolute way of comparing time values?

0 Kudos
Message 7 of 10
(6,960 Views)

Just combine it with nathand's code. Replace the code in the true case of the case structure with this and it should be called once a day. You still need the day of month shift register but you can remove the other two. [Edit - I was going to say you should make my code a subVI of nathand's code]

=====================
LabVIEW 2012


0 Kudos
Message 8 of 10
(6,953 Views)

On a slightly different approach.

 

When ever the customer allows (and they often change their mind if I suggest this tip).  My project data folder contains reports with this name format.

 

"JJJJJ_ProdData.*"  where JJJJJ is a 5 digit julian from the current timestamp formated to string with the specifier "%y%j" (Year within Century, Day within year.

 

files are created in windows explorer default sort order newest at the bottom. (for the next 87 years and 11 months anyhow- I've got time to come up with a better plan by then)


"Should be" isn't "Is" -Jay
0 Kudos
Message 9 of 10
(6,947 Views)

@Steve Chandler wrote:

Just combine it with nathand's code. Replace the code in the true case of the case structure with this and it should be called once a day. You still need the day of month shift register but you can remove the other two. [Edit - I was going to say you should make my code a subVI of nathand's code]


You could just use Steve's code to initialize the shift register in my code; no need to execute it every time unless you expect some other application to be dumping conflicting-named files in the same directory at the same time.

0 Kudos
Message 10 of 10
(6,937 Views)