LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Read from spreadsheet

Solved!
Go to solution

Hello,

 

I'm having strange issues trying to read from the following spreadsheet file. I'm using a similar structure for 2 other spreadsheet files and they work perfectly. When I try and use the following VI with the attached data file it just seems to import a load of zeros.

 

I'm wondering if the issue could be related to the delimiter as the data is not just comma separated values but there seems to be a space directly after the comma i.e. "18.63, 18.23, 17.53" as opposed to "18.63,18.23,17.53".

 

Can anyone help me with this? I'm just trying to get some temperature sensor data from a datalogger. The data is being written to the spreadsheet continually and I'm just trying to read the most recent value so that I can use it for further calculations.

 

Thanks in advance,

 

Barry

 

VI.png

0 Kudos
Message 1 of 21
(3,675 Views)

Your data is filled with null characters.  Turn on \codes display on the indicator and you'll see a whole lot of \00 's.

 

Also has a \FF\FE at the beginning, possibly some prefix for a special file type?

0 Kudos
Message 2 of 21
(3,657 Views)

RavensFan,

 

I'm not sure I follow what you're saying. Inside the CSV file the data looks fine to me? 

 

See the below photo: 

 

Data.png

 

 

Also, the front panel when you import the file seems to import the raw data fine and you can clearly see the data. I'm just trying to extract each of the individual elements into double format so that I can display and use them for calculations.

 

You'll see that none of the data is showing up in "sub array 3" as individual elements. For the other CSV file I use this method seems to work fine?

 

Front panel.png

0 Kudos
Message 3 of 21
(3,649 Views)

Also, what is the purpose of the while loop and stop button? Does the file contents really change millions of times per second forcing you to re-read the same file over and over as fast as the computer allows?

 

What was originally used to create that file?

0 Kudos
Message 4 of 21
(3,646 Views)

Right click on your indicator and display \codes mode.  You'll see \00 every other character.  Even in normal display, the text doesn't look right with "spaces" between every character.

 

I think it is somehow encoded as unicode.  I think that is what the \FF\FE at the front of the file signifes.

 

Excel is probably reading a unicode CSV file okay.  LabVIEW reads it as a straight up "text" file with a bunch of null characters all over the place.

 

If you use search and replace, to replace the null characters with nothing, it works fine.

 

See the attached snippet.

0 Kudos
Message 5 of 21
(3,645 Views)

This file might be in unicode or something. What is the language setting of the computer you are using?

0 Kudos
Message 6 of 21
(3,638 Views)

The file is being updated once per second by Agilent Bench Logger 3 software that is communicating with an Agilent 34972A LXI Data acquisition unit.

 

The reason I'm using the while loop is because it was the structure that seemed to work with my previous program. It's almost certainly not the best way to do it but for my needs to worked at the time so I've stuck with it.

 

In relation to the fix that you suggested - can you give me any solution to how I would implement the functionality that I'm trying to achieve? I basically want to be able to pull each of those individual data elements out once a second as the CSV file is being updated? Do I have to get LabView to delete all of the zeros some how?

 

Thanks for the help so far,

 

Barry

0 Kudos
Message 7 of 21
(3,635 Views)

The langauge setting is ENG UK 

0 Kudos
Message 8 of 21
(3,634 Views)

NULL Characters don't show up in normal display mode that's why Ravens Fan told you to switch to code display.

You can do something like this

 

read spreadsheet.png

 

There is surely a better way to have the latest values than to write to a file and then read back the file to get the latest value. (and put a small wait time in the while loop to slow it down a bit)

 

EDIT: I missed a lot of replies while typing so sorry for the redundancy!

 

Ben64

0 Kudos
Message 9 of 21
(3,627 Views)

@Barry675 wrote:

 

In relation to the fix that you suggested - can you give me any solution to how I would implement the functionality that I'm trying to achieve? I basically want to be able to pull each of those individual data elements out once a second as the CSV file is being updated? Do I have to get LabView to delete all of the zeros some how?

 

Thanks for the help so far,

 

Barry


See the snippet that I attached to my post.
0 Kudos
Message 10 of 21
(3,618 Views)