LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Read from specific cell in csv file

Hi 

 

Im trying to read from cell #14 (means collum #14 ).

Is there a quick way to read only this cell?

Or do I need to read all the cells before him?

 

tnx.

Adi.

 

0 Kudos
Message 1 of 6
(4,710 Views)

I think this depends a bit on what you call 'read'...

 

If you are reading a file this is a sequential process so you need to read all lines and all columns up to the desired one.

You can sort of hide part of this process by using a scanning function such as ScanFile () or fscanf () which may return only the desired value.

0 Kudos
Message 2 of 6
(4,703 Views)
You are right...
I should have written more details...
These r the functions i use :
FileOpen
FScanf
My question is how to use fscanf (what the syntax if exist) so pull only the context in this cell (#14 in this metter)?
I dont need to use the first 13 cells...
Tnx .

0 Kudos
Message 3 of 6
(4,701 Views)

This is an example for column 4...

 

You can test it in the Interactive Execution Window

 

#include <ansi_c.h>    


static float result4;

 

sscanf ( "1.0 2.0 3.0 4.0", "%*f %*f %*f %f", &result4 );

printf ( "%f", result4 );

Message 4 of 6
(4,699 Views)

Thanks Wolfgang! You opened me a new world with that asterisk flag! Till now I was always using Scan when I needed to discard part of the scanned string!

Here's where a good basic C course -which I'm missing- comes in handy



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 5 of 6
(4,676 Views)

Had to adapt it to 14 cells, and to strings\int\double veriables...

but it worked 🙂

tnx !!

0 Kudos
Message 6 of 6
(4,655 Views)