02-09-2017 12:22 PM
Hi everybody,
the title is pretty self explanatory. I'm trying to make several mesaurements and save them in the same TDMS file but each set of mesaurements in a different sheet named with an incrementing suffix. Probably it's a simple request but I can't find the answer.
Thank you
Davide
Solved! Go to Solution.
02-09-2017 12:31 PM
You have two options here...
First option is you just store a base path. Every time you save a file you store the current number in a shift register, increment it, number to decimal string, concat strings, and build path.
The second option is use the attached code. It will check if the file is unique. If it is, it just saves the file. If not it acts like windows and will add (1), (2), (..n) to the end of the file.
02-09-2017 12:51 PM
I made an idea exchange item on creating a unique file name, without creating the file. There are a few options but the one posted by Bowen certainly works. Go vote for my idea if you think it should exist.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
02-09-2017 01:49 PM - edited 02-09-2017 01:50 PM
@Hooovahh wrote:
I made an idea exchange item on creating a unique file name, without creating the file. There are a few options but the one posted by Bowen certainly works. Go vote for my idea if you think it should exist.
And while we are wating for that...
LV 2015 has a "Create File with Incrementing Suffix.vi" in the file -advanced pallete. It is a VI that can be kit-bashed to eliminate the file creation.
And...
In the event the original poster wanted a new sheet to show up when using the Excell add-on to import TDMS files, the "group" input to the TDMS file write will dicate the tab where the data is shown when opened in Excel.
Ben
02-10-2017 03:56 AM
Thank you BowenM for the answer.
I've just realised the title isn't self explanatory at all. I'm sorry for the misunderstanding. The code you attached will create a new file (that i will probably open with Excel) if there is no other file with the same name. Otherwise it will create a new file with that name followed by an incrementing number. This could be helpful indeed, but I'm trying to add sheets of data (corrisponding to groups as rightly notified by Ben) inside an already existing file, and I need those sheets to have an incrementing number. Probably the structure of the code will be the same, I simply thought there was an easier and "built in" way to do it. If you have any suggestion in this sense please let me know.
Thank you for your time
Davide
02-10-2017 07:38 AM
Yeah I was a bit confused. You said the title says it all, then go on to talk about TDMS groups. In any case you can modify the code posted earlier which looks at file names and if they exist, and can change it to look at the contents of a TDMS file and seeing which groups exist, and then increment a number the same way.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
09-30-2018 04:07 AM
When i use the "Create File with incrementing Suffix.iv" for storing filename with already a number in name, for ex. abcd12ret. the first file created is a unique name. the second file created will be abcd12ret013, the third file is abcd12ret014 as opposed to getting abcd12ret001 and abcd12ret002.
The problem remains the same if applied to filenames like abcd12 where the next filename should be abcd12001
Can you send this file ? i want to try this.
10-01-2018
08:12 AM
- last edited on
05-06-2025
04:38 PM
by
Content Cleaner
@SanjoyJena wrote:
Can you send this file ? i want to try this.
If you are referring to the VI image from earlier, then this is a VI Snippet and can be dragged to your block diagram from most browsers. Here is a link to the image, and here is an article on snippets. The image contains the VI inside it.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
04-06-2022 05:45 PM
Kind of a dumb question but is there an example for writing with a TDMS file? Basically the VI below works fine (w/o the "Create file with incrementing suffix") but I wanted it to automatically increment the file names between use.
Works:
Doesn't work:
Like I said, WITHOUT the "Create file with incrementing suffix" vi it works, but if I put "create file with incrementing suffix" before TDMS open (as pictured above) I get errors with file permission There's OS or disk-based file permission issues. I guess it's trying to be open in two places?
04-11-2022 12:10 PM
@olliejk wrote:
Doesn't work:
Like I said, WITHOUT the "Create file with incrementing suffix" vi it works, but if I put "create file with incrementing suffix" before TDMS open (as pictured above) I get errors with file permission There's OS or disk-based file permission issues. I guess it's trying to be open in two places?
Yeah that likely is the problem. The Create File with Incrementing Suffix is creating a file and opening a reference to the file. That file is now locked to be written to. You then try to open another session to the file for the TDMS and it generates an error. The easy solution is to use the Close File after the Create File, but before the TDMS Open. This is why I created the idea exchange to just create a file name, not open a reference to the file.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord