LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Date Time as Filename - What did i do wrong?

Solved!
Go to solution

Hello

 

Newbie back again asking silly questions. 

 

So. I am logging strain gauge data, and writing to a CSV. this is working well, but... My files is getting huge. 

 

I dug around a little and looked at examples, and tried to replicate that for mine so that it writes a new file automatically every day, rather than writing until it can write no more and then having a meltdown. 

 

This is what I have come up with so far, but try as I might, I cannot get it to work (I just get various errors about file names when I start the program). 

 

If i leave it with just an empty blank file name, obviously it brings up a dialogue box asking me to give it a name. 

 

I am still tinkering, but I don't use labview very much and I am still trying to get to grips with how it works. So sorry for asking such a newbie question (again)! I'm keen to learn but I really don't get chance to play with labview very much. Very much appreciate the help and support given on here so far (posts and help to others has been massively helpful to me!). 

0 Kudos
Message 1 of 16
(3,329 Views)

Hi Dave,

 

This is what I have come up with so far, but try as I might, I cannot get it to work (I just get various errors about file names when I start the program).

Which errors do you get?

 

Once your VI is running the loop your filename will never change anymore - THINK DATAFLOW!

So when the filename should change inside the loop you need to put the filename creation part inside the loop: DATAFLOW…

 

It would also help a lot (for readability) if you would clean up your VI!

Best regards,
GerdW


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

As GerdW said, once you start your program, your file name is not going to change. Is this a program that you run a couple times a day, and it's ok for the data to go into the same file?

 

By the way, your format string has the time in it (%H%M%S) so if you run the program twice, even just a second apart, it will create two separate files. You should probably take that out if you only want 1 file per day.

 

Also, when using the multiply function, you can use a single value to multiply each element by that value.

 

What do you have in your FilePath control? If it is empty, I assume you would get some errors. It should be the folder where you want to store your file.

0 Kudos
Message 3 of 16
(3,248 Views)

Your browse control is set to select new files (right-click...browse options), but then you treat that new file as path, trying to use "build path" with the file as "base path" input. This will not work.

 

You have several options:

 

  • Change the browse option to select or create a folder
  • Select a file, but then strip the filename, append the time string, and built a new path with the based path and the combined file name.

 

 

0 Kudos
Message 4 of 16
(3,242 Views)

By now you know that your method of managing file names is seriously flawed, but presumably you understand how to fix it so that you can loop and have the name update for each loop.

 

I'd like to address something else -- why are you using a TimeStamp for the file name?  I have a colleague who does this, and he ends up with file names that are "Human-hostile", hard to read, full of characters, much too long.

 

 

I would suggest that you choose a file name that makes sense to the User of your data and reflects a characteristic of the dataset, maybe something like "Strain Data".  If you look at the functions in the Advanced File VIs and Functions, you'll find "Create File with Incrementing Suffix".  If you used this function and always gave it the fixed name "Strain Data", it would create files "Strain Data", "Strain Data (1)", "Strain Data (2)", etc.  If you had several sets of Strain Data, you could put them in separate folders, "Experiment 1", "Experiment 2", "Experiment 3", each with a set of "Strain Data" files (there's nothing wrong with repeating the same file name or file name pattern if the enclosing folders are different).  From a User perspective, handling sets of files with such a "logical" and "human-readable" file naming scheme might be friendlier ...

 

Bob Schor  

0 Kudos
Message 5 of 16
(3,235 Views)

Hi. Thank you for taking the time to respond!

                                               

I will run the different configurations I have tried and post the errors.

 

The original VI is not one I built, it is legacy from another project gathering data that a different project now requires. The original designer has long since left, and so I am trying to learn as I go to make it work. I will try and tidy it up too.

 

The idea is to set the program running, and to leave it recording indefinitely. I want it to create a new file every day, it does not matter what the file is called provided it is sequential and, for preference, has a date in the file name. At the moment, the way I am running it is to simply manually name a file when it is set to run, which is being saved on a shared drive. The file name formate does not matter, the data is being used by a program not by a person. It also does not matter if I save as a file on another drive, or if the data is simply sent directly over the web (though I really cannot suss out how to do the latter). I'm just using whatever I can make work really...

0 Kudos
Message 6 of 16
(3,217 Views)

gregoryj

 

It doesn't matter really about the format of the name. I need it to run, without intervention, and to autumatically save a new file each day without it melting down and stopping when one thing or another gets full.

 

Filepath control is indeed empty. I am heading over to the lab where this thing is later to tinker some more.

0 Kudos
Message 7 of 16
(3,210 Views)

altenbach

 

I am sure when I look back at the program later today, I will see what you mean and spot where I went wrong. I will look and let you know!

0 Kudos
Message 8 of 16
(3,209 Views)

Bob_Schor

 

Yep. I a now know it's flawed and doesn't work. How to fix it, in principle yes I understand, but until I am sat in front of it again I won't know if I know how to fix it!

 

Timestamp is just because that's what I tried at the time. Humans aren't going to be reading or using the data directly. It will be read by a program and assembled into a visualisation, so the format of the filename is insignificant provided there is a logical structure to it what we can then use a python script to make use of.

0 Kudos
Message 9 of 16
(3,208 Views)

Hi Dave,

 

The idea is to set the program running, and to leave it recording indefinitely. I want it to create a new file every day,

Then you need to put the filename logic inside of your indefinitely running loop - THINK DATAFLOW!

Some pseudocode to give an idea:

IF day(time(now)) <> day(time(last iteration)) THEN
    generate new filename and file
ELSE
    use old file
ENDIF

Note: you don't need to create 3 4 posts in a row to answer to several messages…

Best regards,
GerdW


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