LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

read csv file to graph?

Hi! there.
 
Can anyone help me?
 
I made a csv file from DAQ mx.
 
This file Format is
 
 date(ex: 2007-09-16 11:40:32),data1,data2....
 date(ex: 2007-09-16 11:40:32),data1,data2....
 
I want to draw this file to X,Y Graph or Chart.
 
But I can't convert this into 2D array.  When I covert this into Date by using read from spreadsheet file .vi, Date is converted like this 2007.000
 
How can I do that?
 
Could anyone infrom me about this solutions?
 
regrads.
 
Kevin.
 
 
 
 
 
0 Kudos
Message 1 of 9
(13,101 Views)

What version of LV are you using ? From LV 8.x, the Read from Spreadsheet File.vi has become polymorphic & it gives output in the form of 2D array also. See the pic...

If you re using LV 7.x or below, you ve to convert the String output you got from the Read File.vi, into a 2D using the Spradsheet String to Array.vi...

- Partha ( CLD until Oct 2024 🙂 )
0 Kudos
Message 2 of 9
(13,084 Views)

Thanks a lot Partha !

I'm using LV 8.2.

I attached my file.

please check my file..

 

Thank you.

Kevin

 

 

 

0 Kudos
Message 3 of 9
(13,079 Views)

You ve forgot to attach the .csv file with your VI; never mind...

Change the polymorphic selector to String instead of Double & create corresponding new indicators and run the VI.

I think you ll get what you wanted.

- Partha ( CLD until Oct 2024 🙂 )
0 Kudos
Message 4 of 9
(13,063 Views)
Congratulations, Kevin. You are the new entry in our Rube Goldberg gallery. Your while loop is an effective way to overaccomplish what you can do with this:

Also, you should not be basing the location of the path to read from the location of the VI. You should use a file path control because:

    (a) You cannot assume the file to read is in the same location as the VI
    (b) If this VI is build into an application the path will be different.

As Partha noted, since you have the timestamp information the way you do, you will need to read the file as a string. Also, you seem to be using the "first row" output, which won't do you much good, since the timestamp information is the first column.

Message Edited by smercurio_fc on 09-17-2007 10:30 AM

Message 5 of 9
(13,050 Views)


@smercurio_fc wrote:
Also, you should not be basing the location of the path to read from the location of the VI. You should use a file path control because:

    (a) You cannot assume the file to read is in the same location as the VI
    (b) If this VI is build into an application the path will be different.

Yes, if you built an application, the relative path will be different. Also, if the application is properly installed in the "program files" folder, there will be potential problems in windows Vista if you want to write there.

Still, in a simple development environment it is often convenient to keep data next to the VI in order to test code, so relative paths make sense. Here's the (near) equivalent code to whatever you constructed with the while loop.

It is very important to never (!!!) use path-to-string and string-to-path when manipulating paths, because it will immediately break the code on a different platform (windows, mac, linux). You should use "strip path" and "build path" exclusively! Paths should never exist as strings, just a paths.

Small differences:

  1. In this particular case you need to ensure that the "sub folder" control is not an empty string or you get a <not a path> as output.Your code would just ignore the subfolder.
  2. Your code also requires the sub folder control to end in a "\", while my alternative only needs the name. If you don't end it in a "\", the subfolder will be merged with the filename.

Exception:
The only place where path-to-string and string-to-path should be used os for OS specific tasks, such as forming a commandline for "system exec".

Message Edited by altenbach on 09-17-2007 09:04 AM

Message 6 of 9
(13,039 Views)

parthabe, smercurio… ,altenbach  Thank you so much.

I solved my probledm of the program.

Thank you so much!

regards

Kevin

 

0 Kudos
Message 7 of 9
(12,990 Views)
A few pointers for your last code:
  1. The only time you need an xy graph is in situations where the x-values are NOT equally spaced. So all that song and dance to generate the xy data is useless.
  2. Whenever the x-data is equally spaced, you should use a waveform graph. You can scale the x-axis any way you want using the x0 and dx property.
  3. Anyway, to build the xy array, you should use an autoindexing output tunnel instead of using "built array".

Attached shows a quick cleanup. As mentioned, all you really need is the array subset and waveform graph. Isn't LabVIEW cool?  🙂

Message 8 of 9
(12,982 Views)

Thank you so much.

Thank you for your concern.

Have a nice day!

Kevin.

0 Kudos
Message 9 of 9
(12,976 Views)