LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

reading specific line from a file

Solved!
Go to solution

is there a VI to read specific line from a csv file. I have a csv file too big to load, and unfortunately whlle the read from spreadsheet file, is useful in some cases, you can not specifiy which line to start from, it can only start from the first line.

 

I have seen many other suggestion on past threads, but none of them is a cogent solution.

0 Kudos
Message 1 of 5
(5,045 Views)

Hi ade,

 

you could read the file blockwise until you have reached the correct line, then read the remaining lines (maybe blockwise too) and use SpreadsheetStringToArray to convert to an array...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 5
(5,035 Views)

Thanks GerdW.

 

Can you be more elaborate when you say blockwise, how do you do that.

0 Kudos
Message 3 of 5
(5,027 Views)
Solution
Accepted by topic author ade77

It is absolutely untrue to say that the Read From Spreadsheet can only start from the first line. There is an input called 'start of read offset'.

 

Reading in blocks means using this with a shift register. For example, if you wanted to read 1000 lines at a time, you would specify that as the number of lines to read and the 'mark after read' output would be wired to a shift register on the right and on the left, wired to the 'start of read'. The shift register would be initialized to 0.

Message 4 of 5
(5,014 Views)


Thanks Dennis,

 

The block approach works perfectly.

 

The start of read offset is based on bytes, rather than just lines, so that was why I could not use that.

 

However, the block approach via shift register is superb.

0 Kudos
Message 5 of 5
(4,992 Views)