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.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

plot data from files

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

0 Kudos
Message 1 of 11
(468 Views)

@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.


"Should be" isn't "Is" -Jay
0 Kudos
Message 2 of 11
(465 Views)

Thank you for your reply

how can I do this, because I don't know how long the reading will take to finish?

0 Kudos
Message 3 of 11
(444 Views)

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!

  • What's the reason to iterate over the array of filenames, show each filename for 1s in a string indicator and then read just the last filename?
  • What's the purpose of this shift register???
  • Why do you convert the filename to a path using StringToPath instead of using BuildPath with the folder used for the ListFolder function???
  • Why is there an ExpressVI in parallel to the TDMS functions???

So many questions for such a small VI...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 11
(415 Views)

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.

 

 

 

0 Kudos
Message 5 of 11
(409 Views)

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

0 Kudos
Message 6 of 11
(395 Views)

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:

 

altenbach_0-1720539664624.png

 

0 Kudos
Message 7 of 11
(384 Views)

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

0 Kudos
Message 8 of 11
(367 Views)

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

0 Kudos
Message 9 of 11
(334 Views)

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?

Best regards,
GerdW


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