LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading Text File

Solved!
Go to solution

Hi All,

 

Hopefully this is the correct location to post this. I am trying to read the second, third and fourth column of the data file in excel and determine the min and max of each column. I keep getting 0 as a value, due to the fact when there is no data in the array it is reading as 0, any help on how to either program that zero is not an acceptable answer or how to make it stop reading after there is no more data would be helpful. I am new at this so any explanation would be great, I attached the data file and my program thus far.

Download All
0 Kudos
Message 1 of 12
(4,389 Views)

First, let's correct your message subject.  You are reading data from a text file.  There is nothing here that has to do with an Excel file.

 

Because your data has a row of headers, when you use Read from Spreadsheet file, it is trying to intepret that has data, and since it is just text, it is being converted to zeroes.

 

I would use Array subset or Delete from Array to elminate the first row of data, then use your functions on the remaining array.

0 Kudos
Message 2 of 12
(4,377 Views)

The Read From Spreadsheet VI will read *all* the rows including your header row.

That row is giving you a row of 0.

Any row without numbers also gets converted to 0 this includes blanks.

 

0 Kudos
Message 3 of 12
(4,373 Views)

Ok, so then how would I change it from reading all and converting to 0?

0 Kudos
Message 4 of 12
(4,370 Views)

I used the subset array, but the minmum data is still being recorded as 0.

0 Kudos
Message 5 of 12
(4,367 Views)

@duckse2410 wrote:

I used the subset array, but the minmum data is still being recorded as 0.


Used it how???  You need to ignore the part that is text.  Put down some extra indicators and work with the subset array and be SURE you are removing the part you think you are.

 

P.S.:  Delete from Array is really a better choice for this task (IMHO) but you should be able to use either. Smiley Wink

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019 - Unfortunately now moving back to C#, .NET, Python due to forced change to subscription model by NI. 8^{
0 Kudos
Message 6 of 12
(4,357 Views)

I used it by applying it to the read from file and instead of all rows I attached the subset. I guess what I am getting confused with is how to further modify it when adding the delete array or something like that. 

Download All
0 Kudos
Message 7 of 12
(4,347 Views)

Well you already got it!  You just have to tell Delete from Array which row to remove.  If you hover over the VI connections with the wiring tool (spool) you will see it says Length, Row and Column.  You want to remove row #0 so.....

 

EDIT:  Also don't forget to have the Context Help window open (cntl-h).  It will guide you on what the possible connections are. Smiley Happy

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019 - Unfortunately now moving back to C#, .NET, Python due to forced change to subscription model by NI. 8^{
0 Kudos
Message 8 of 12
(4,329 Views)

I did that and my min values are still reporting as 0. Which is why I am not understanding.

0 Kudos
Message 9 of 12
(4,321 Views)
Solution
Accepted by duckse2410

I just noticed that your minimums are still zero.  You must have some crap at the end of your file.  Delete from array can still work here but now Array Subset is the better choice.  You need to cut off the first row (so first index = 1), then keep only the next 29 rows since that's all the data in your CSV table.

 

Again, set up some extra indicators and run your VI many times with different numbers for index, length, etc.  Play around and learn what the array VIs can do.

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019 - Unfortunately now moving back to C#, .NET, Python due to forced change to subscription model by NI. 8^{
Message 10 of 12
(4,310 Views)