From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, 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: 

How to Add points on graph from a text File ?

Hello and Good Morning to all,

 

I have a text file with my data and i read them by using the Read From Spreadsheet File VI,i enter the path where my file is saved,read all rows delete the first row because i don't need it and my problem is that in the text folder i have specified date and time which i want to be my X axis in my Graph and Y axis to be the Vout that means i have to use a XY Graph ,below you can see my data:

 

Date        time              Vout  
3-9-2012 7:45:37            2,35
3-9-2012 7:45:39            2,75
3-9-2012 7:45:41            3,15
3-9-2012 7:45:43            3,50

 

1) Is the text file format compatible with the input of the graph command?

I do not find a LabVIEW function which convert the “date” from the text file (example:3/09/2012 07:45:37) into a compatible format for X axis for the graph.

(Conversion from string format => into a “date and time” format)

 

Can someone please provide a code solution for this problem?

 

 

0 Kudos
Message 1 of 10
(2,770 Views)

Hi gstathatos,

                         See all the threads given below:-

                         http://forums.ni.com/t5/LabVIEW/Add-points-on-XY-graph-with-time-step-not-constant/td-p/1507066

                         http://forums.ni.com/t5/LabVIEW/Add-points-on-graph-from-a-text-File-Date-and-time-include-in/td-p/1...

                         http://forums.ni.com/t5/LabVIEW/read-double-waveform-text-file-and-and-plot-graph-in-labview/td-p/10...

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Thanks as kudos only:)
0 Kudos
Message 2 of 10
(2,764 Views)

Hi Danil 33,

 

I saw the link you send me and unfortunately the information from the second and the third link is not working as it should.From the first link i try to understand if i can use it.

Any other code suggestions?

0 Kudos
Message 3 of 10
(2,753 Views)

Hi gstathatos,

 

you could use ScanFromString easily:

check.png

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 10
(2,743 Views)

Hi GerdW,  my data is being read from a text file so i use your vi along with reading the data from my text file but unfortunately is not working.In my graph on x-axis i don't see the time i have in my text file.I am sending you my vi maybe i am doing something wrong and you can fix it. 

0 Kudos
Message 5 of 10
(2,735 Views)

Hi gstathatos,

 

two points:

- your Format string has a typo, there's a "<" too much...

- I would format the x axis of the graph as "absolute time" instead of float numbers...

 

Ever considered to press the cleanup button?

Best regards,
GerdW


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

Ok correct those two mistakes you told me but my problem remains in the x axis i can't see my time i have in my text file

0 Kudos
Message 7 of 10
(2,722 Views)

Hi,

 

and what do you see instead when it's not the correct time?

Best regards,
GerdW


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

In my XY Graph the X axis is as shown in the picture.I expect to see in my X axis the time i am reading from my text file.

0 Kudos
Message 9 of 10
(2,718 Views)

Hi gstathatos,

 

you know you can change the formatting of the x axis to show also seconds and year?

You know you can check your data by using probes or indicators?

 

Are the timestamps read correctly from your text file? Did you check that?

 

You know debugging isn't easy when I'm not sitting in front of your computer!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 10 of 10
(2,715 Views)