LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to read second last and last row of csv file

Hello

 

my data is stored in csv file daily in row as i attached file.

i want to read its second last and last row of data.

how can i do that.

 

need any suggest and guide.

 

Thanks

asif 

 

0 Kudos
Message 1 of 19
(3,827 Views)

Read the complete csv-file and select the last two rows within LabVIEW.

 

Regards, Jens

Kudos are welcome...
0 Kudos
Message 2 of 19
(3,824 Views)

lr.png

"If you weren't supposed to push it, it wouldn't be a button."
Message 3 of 19
(3,808 Views)

You have attached a file in a proprietary xlsx format, nothing resembling CSV. Can you attach the CSV file instead?

 

How big is the file getting over time? Do you have a reasonable upper limit on the number of characters in a row (=line). From the files size you can guess a reasonable file position that includes the last few lines and parse from there.

0 Kudos
Message 4 of 19
(3,776 Views)

hi 

 

please see attached csv file, i just want to read yellow highlightened fields, no need to read colum headers and time.

data is saved at 8am and 8pm.

 

thanks,

asif 

0 Kudos
Message 5 of 19
(3,748 Views)

hi

 

sorry to say, i actually saving file in xls format, please consider xls file and suggest.

 

thanks

asif 

0 Kudos
Message 6 of 19
(3,746 Views)

Hi

 

i just try by modifying example code and have attached here.

now i want how can i set end address of get data as my row and column.

 

Thanks

asif

Download All
0 Kudos
Message 7 of 19
(3,693 Views)

Hey Asif. What do you mean by setting "end address of get data"? Like getting all data up to a row, column coordinate? Either way, I'd recommend two things. 

1: Write data to a more neutral format than .xlsx, like a true delimited text file like a .csv. That way you don't need to use special toolkits to read Excel files or other formats. Everything can read a text file!

2: If you have to use Excel files and the Report Generation Toolkit, read the whole file and then dissect it to get what you want. Remove headers, select rows, select columns, whatever you want to do, but do it to the whole table instead of cutting out data at the read step. I find it's usually easier and if some day you decide you want to use those headers or other rows or columns, you just modify what you do with the data instead of modifying what data you're importing, which might affect the other functions you're already doing on the data, shifting rows or columns and making you have to go revisit your other functions. 

 

I attached some basic table reading operations. Maybe you can get some hints on what you're trying to do there?

0 Kudos
Message 8 of 19
(3,681 Views)

You can get the position of the last row using "excel get last row" and calculate the start and end positions from there. May need a tweak or two, nothing a +1 or -1 cannot fix. 😄

 

altenbach_0-1628263896582.png

 

(And please clean up your code before attaching a snippet. Having overlapping wires flowing in all directions is not helpful)

 

0 Kudos
Message 9 of 19
(3,671 Views)

Thanks for your replay

 

please send me snippit.

 

asif

0 Kudos
Message 10 of 19
(3,659 Views)