From Saturday, Nov 23rd 7:00 PM CST - Sunday, Nov 24th 7:45 AM CST, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Saturday, Nov 23rd 7:00 PM CST - Sunday, Nov 24th 7:45 AM CST, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
07-09-2024 07:37 AM
Good morning
I have a problem in my program, I have a folder where there are tdms type data files what I want to do is to plot the data of each file on the same graph. For this I use vi to read the data, in my code I can browse the files in my folder but I can't do the reading, my problem is that the file names change much too quickly that I can't read them. read what causes me to get error code 7,
Can you help me with this please?
thanks in advance
07-09-2024 07:42 AM - edited 07-09-2024 07:46 AM
@ameletudiante99 wrote:
Good morning
I have a problem in my program, I have a folder where there are tdms type data files what I want to do is to plot the data of each file on the same graph. For this I use vi to read the data, in my code I can browse the files in my folder but I can't do the reading, my problem is that the file names change much too quickly that I can't read them. read what causes me to get error code 7,Can you help me with this please?
thanks in advance
If something is renaming your files while you want to read them you need to pause that other process. Alternatively you could simply sacrifice your sanity.
07-09-2024 08:03 AM
Thank you for your reply
how can I do this, because I don't know how long the reading will take to finish?
07-09-2024 09:06 AM - edited 07-09-2024 09:07 AM
Hi Amelie,
@ameletudiante99 wrote:
I don't know how long the reading will take to finish?
The reading itself will be quick.
The most time is needed for that senseless FOR loop in your VI!
So many questions for such a small VI...
07-09-2024 09:23 AM
Hi
thanks for your answer
I save my acquisition data on several files but I want to trace all the data.
This is to send the string to the outside of the for loop
I did this just to test what might work;
the files are created every 10 minutes so at the end of the acquisition I don't know how many I have?
what I want is to browse a folder and plot the data in a graph
my approach and may not be correct can you direct me towards a simpler solution.
07-09-2024 10:01 AM
It doesn't sound (to me) like you are doing anything that is difficult, but I have to confess I don't know precisely what you want to do. I gather that you have a process that generates multiple TDMS data files, but you don't provide much information about these files (other than mention somewhere that they are generated every 10 minutes, and are probably all saved in the same place, but distinguished by some naming convention). You want to do something with these files at some time, possibly while they are being generated, or after the file-generation routine has been run.
So the first question is whether there are two separate routines (a Data Generator/Writer and a separate in "time and space" Data Analyzer/Reader) that are run sequentially, or whether there is a single routine that "analyzes" (or at least plots) the data as it is being generated.
Neither your description nor the code fragments I've seen clarify this. It looks like you have separate routines, which means that the Analysis routine simply needs to get an array of the TDMS files and (in a For Loop) sequentially process and plot each one. Of course, now we get the question "Do you want a single plot showing all of the data from multiple files plotted together, or do you want a separate plot for each TDMS file?". I don't know the answer to that, either.
Once you clarify what you want to do, figuring out how to do it becomes much simpler.
Bob Schor
07-09-2024 10:36 AM - edited 07-09-2024 10:41 AM
Do the file names actually change or do you simply have more and more files. If another process is still writing to a file, you might not have read access doe to locking.
Your code makes very little sense and it is also not clear in what order you want to read the files (alphabetically? By last modification? etc.)
It seem you want to read and append all matching files, so why do you read only one?
Just iterate over the listed files and read them inside the loop (while ignoring fines that fail to read), appending all data. Make sure to use "build path", Converting a filename to a path will not give a valid file path.
See if this can give you some ideas:
07-09-2024 01:17 PM
Hi,
I want to plot all of the data on the same graph and I do it after I have generated all my tdms files.
thank you for your advice I will be able to test this tomorrow at the office
07-10-2024 03:17 AM
Good morning ,
I took your advice into account, it corrected my problem but the data overlaps!
how can I trace the data on the same graph, that means the data from the first file next to the data from the second and so on.? I tried with several functions but either the signals overlap or I only trace the last signal
thanks in advance
07-10-2024 04:32 AM
Hi Amelie,
@ameletudiante99 wrote:
I tried with several functions but either the signals overlap or I only trace the last signal
What exactly did you try?
Why don't you attach your tries?