LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to read data from a .txt file in real time

Hi
 
I am running a fortran code which takes around 1 week to run and output data are continuously saved in .txt files. I want to display these data and plot it against time in labview.
 
Lets say I have a array of real numbers starting from 1.0 , and every 2-3 sec another number is added (output of code). So I dont want end-of-file-reached error in my program and also want program to wait until next data is updated in .txt file.
 
I tried to make a simple read_txt_file.vi, but I am getting problems in terms of continous reading. Help !! Help !!
 
Pl see the attached vi.
 
Thanx
PKJ
Download All
0 Kudos
Message 1 of 11
(5,227 Views)

Hi PKJ,

      I modified your VI and it seems to do what you asked, that is, display the data from a file as the data is being added.

Hope it helps!

Message Edited by Dynamik on 11-08-2005 04:32 PM

Message Edited by Dynamik on 11-08-2005 04:34 PM

When they give imbeciles handicap-parking, I won't have so far to walk!
Message 2 of 11
(5,222 Views)
Thanx a lot Dynamik, the .vi you attached is working well. Could you please explain your changes a little bit. I am a newbie user of LV and trying to learn some concepts. 🙂

The idea which I got from the block diagram is that you are comparing file sizes (new and previous one) and if both sizes are not equal than "read file" case becomes true. Could you please explain it further...in terms of handling of end_of_file error. Thanks a lot for your help.

PKJ
0 Kudos
Message 3 of 11
(5,203 Views)

Hi PKJ,

      You're welcome!  Here's the VI again - with comments.

Cheers.

When they give imbeciles handicap-parking, I won't have so far to walk!
Message 4 of 11
(5,195 Views)
Hi Dynamik,
 
Thanks again for your modified VI.
 
Now I want to display a graph also on the front panel (x-axis is first column in .txt file and y-axis is second column in .txt file, which is getting updated in real-time)  I dont know where in the block diagram, i should connect xygraph etc. 😞
 
I am attaching both vi and the text file. Please have a look and help. 
 
PKJ
0 Kudos
Message 5 of 11
(5,175 Views)
sorry, i forgot to attach. here are the files.
Download All
0 Kudos
Message 6 of 11
(5,175 Views)
Hi PKJ,
   If possible, I'd modify DAQ program to save two files one text, one binary.  Save the text for your Test-data record and use the binary for this real-time display.  If that's not feasible, you may want to think about maintaining a current record pointer - an offset from start of file to last EndOfLine.  Every loop, read all new text and look for new EOLs - converting all the text in-between - then update the "current record pointer" to the last EOL you find.
 
Cheers!
 

Message Edited by Dynamik on 11-09-2005 08:43 PM

When they give imbeciles handicap-parking, I won't have so far to walk!
0 Kudos
Message 7 of 11
(5,172 Views)
Hi PKJ,
 
When they give imbeciles handicap-parking, I won't have so far to walk!
0 Kudos
Message 8 of 11
(5,165 Views)
Hi PKJ,
  
When they give imbeciles handicap-parking, I won't have so far to walk!
0 Kudos
Message 9 of 11
(5,165 Views)
Dynamik
thank you very much!
I learned a lot!
0 Kudos
Message 10 of 11
(5,089 Views)