LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Is there a way to select a certain box of elements from a csv file and read that into LabVIEW?

Solved!
Go to solution

Hello all, I was wondering if there was a way to select only a certain "box" of elements from a .csv file in LabVIEW? I have LabVIEW 2011 and my main goal is to take two arrays and graph them against each other. I can import the .csv file just fine and separate each row and each column to be its own, but say I have an 8X8 but want to graph the middle 4X5 or something like that. Is there any way to extract an array without starting at the beginning and without ending at the end? Thank you in advance.

0 Kudos
Message 1 of 9
(3,144 Views)
Solution
Accepted by topic author Szklanam

Hi Szklanam,

 

as a CSV file is just a TXT file with a different suffix you can read a certain number of lines of that file. So you can limit the number of rows in your resultung array. To limit the number of columns you still have to use ArraySubset, so maybe it's a lot easier to read the full CSV file and pick the interesting spots with ArraySubset...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 9
(3,141 Views)

Yes. You have the "Array subset" primitive that can extract a part of an array and doesn't necessarily start from the beginning.


We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

Message 3 of 9
(3,139 Views)

Array Subset

 

If you're asking about reading a specific chunk from the file, then you'd need to have a file that is fixed-format, so you'd know exactly at which byte to start reading, and how many bytes to read. Most CSV files are not.

Message 4 of 9
(3,138 Views)

3 similar answers in the same minute!

Smiley Very Happy


We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

0 Kudos
Message 5 of 9
(3,135 Views)

I will try this and see how it works out. Thank you

0 Kudos
Message 6 of 9
(3,129 Views)

Yes this is exactly what I had been looking for. All the tutorials I had tried to look up online mentioned nothing about this. It was all about starting at the first element and it was really getting on my nerves. Thank you all, much appreciated.

0 Kudos
Message 7 of 9
(3,119 Views)

Hi Szklanam,

 

If this issue has been solved, would you mind marking the solution?  This helps because it lets other people looking for answers know that the solution to the thread has been found without having to read through the posts.  Thanks!

Jeff S.
National Instruments
0 Kudos
Message 8 of 9
(3,086 Views)

Three equivalent answers, one solution choice...  WHO will get the glory??? Smiley Surprised

 

EDIT: Wow, that was quick.  Congrats GerdW!  Don't spend it all in one place.

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 9 of 9
(3,070 Views)