LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Read data from spreadsheet

Hi NI Community, 

 

I'm trying to read data from a .csv file (saved from Excel) in LabVIEW 2013 and cannot understand why I keep getting the same error.  I am using the "Read From Spreadsheet File" VI to accomplish this.  I need to read in the data and store it in an array.  When I try to compile and run the code on my myRIO, I get an error that says, "File not found.  The file might be in a different location or deleted.  Use the command prompt or file explorer to verify that the path is correct."

 

I have the file saved in the project folder with the rest of my files for this code, and that's the location I am giving to the Read From Spreadsheet VI.  I am running LabVIEW on a virtual machine with a shared drive on my Mac, but I tried saving the .csv locally and it still didn't work.  I was told it may have something to do with the fact that I'm running the code from the myRIO, not my computer where the file is actually stored, but I'm not sure.  Even if that is the problem, I wouldn't know how to solve it.  I have 3418 data points that I'm reading in, so I would really prefer to not have to manually put them into an array.

 

If anyone could help me figure this out, I would appreciate it immensely! 

 

Best, 
Emma

0 Kudos
Message 1 of 10
(4,410 Views)

That file needs to be on the myRIO itself.  It cannot just read stuff from your harddrive.  It has its own.

 

Think of it as another computer and it all makes sense.  You wouldn't expect another computer to get "C:\blah\temp.txt" and be able to read the file in that location on your computer.  But you can make a shared folder on your computer and then another computer can read the files in that folder using the network address.  This is the method I normally recommend to people to use.  Make sure your myRIO is using the network address.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 10
(4,405 Views)
As you said you cannot read the file which is saved in you local drive in a different target. Why do you want to open the file in a RIO target? Just because you need the data points? If that is the case you have to read the file under My computer and then pass the data to the RIO target.
-----

The best solution is the one you find it by yourself
0 Kudos
Message 3 of 10
(4,403 Views)

Thanks for both your responses.  

 

I want to open the file on the RIO target because I need to read the points, then use them as position data to send to a motor that the myRIO is controlling.  I already have the control software written, I just need to import the points so the motor knows where to go.  

 

Does this mean I need the File Transfer Utility, in order to load the file onto my RT target?  I'm currently referring to this document: http://www.ni.com/white-paper/3365/en/

 

Emma

0 Kudos
Message 4 of 10
(4,385 Views)

I'd just use the Windows explorer FTP to put the file on the RIO.  Or if you will always have your computer connected when doing this, make a shared drive on your computer that the RIO can access with a network address.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 5 of 10
(4,377 Views)

Does myRIO need to be connected over wifi to do this?  I just tried adding a network location in windows Computer, using ftp://<ip address> but am not sure if that's the right way to do it.  Sorry, this is all very new to me. 

EDIT: Figured it out.  Needed to use Map Network Drive.  Thanks so much for your help! 

0 Kudos
Message 6 of 10
(4,366 Views)

Right now I'm just trying to read in my data points and output them to a chart, that way I can see that things are working properly.  So when I go into the files on myRIO, I should be able to paste the .csv I need to use there, correct?  Then that's the file path I pass to the Read From Spreadsheet File VI?  That's what I just tried and still got my original error, looking something like this: 

 

Screen Shot 2014-07-25 at 3.54.20 PM.png

0 Kudos
Message 7 of 10
(4,349 Views)

The File Path Control on your front panel shows something like "/R/Forces...".  This is a relative path to a folder called "R" -- is such a folder on your RIO?  Where did you put the file on the RIO?  I'm guessing the file is at "C:\<folder and path to files>" ...

 

BS

0 Kudos
Message 8 of 10
(4,322 Views)

Not sure why I didn't think about his sooner, but here's a really good paper on file paths with the cRIO/myRIO.

Working with File Paths on Real-Time Targets


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 9 of 10
(4,315 Views)

Thank you for the help.  I'm now able to read in my data using the network drive I mapped to on my PC and the file path /home/lvuser/<myfile>.  

0 Kudos
Message 10 of 10
(4,272 Views)