01-31-2012 02:48 PM
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?
01-31-2012 03:02 PM - edited 01-31-2012 03:04 PM
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."
01-31-2012 03:03 PM
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.
01-31-2012 03:05 PM
Thanks! I'll try this and see how it works for my application.
01-31-2012 03:06 PM
Of course, if you can't wait 24 hours to see how it works, unbundle "hours" or "minutes" instead of "day of month."
01-31-2012 03:13 PM - edited 01-31-2012 03:14 PM
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.
01-31-2012 03:33 PM - edited 01-31-2012 03:36 PM
@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?
01-31-2012 03:38 PM - edited 01-31-2012 03:39 PM
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]
01-31-2012 03:48 PM - edited 01-31-2012 03:51 PM
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)
01-31-2012 04:52 PM
@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.