It's possible to pick a specific number in a CSV file based on the location in the text file?

 

Hi, i need help to get a number from a CSV file, and assign it to a variable,  this CSV file is very simple, it only have numbers and commas,


int handle;

int start()       
  {

handle=FileOpen("filecsv", FILE_CSV | FILE_READ);

double val = FileReadNumber(handle);// QUESTION-  in my CSV  the numbers are  10 ,  10 , 10  , 5  , 10   - my question, 
                                       //how to change this variable to always get the 4 number in the row (5) of the file?

Comment (val);

FileClose(handle); 
      

return(0);
};  

Thanks for any help

 
Mrluck07:

Hi, i need help to get a number from a CSV file, and assign it to a variable,  this CSV file is very simple, it only have numbers and commas,


Thanks for any help

I suppose you meant the fourth number in the row. First you have to read over the first three numbers and then the fourth one. If there is comma "," as a delimiter in your csv file you have to  declare it in FileOpen() because the default delimiter is semicolon.
   int handle=FileOpen("file.csv", FILE_CSV | FILE_READ,',');
   double val;
   for(int i=0;i<3;i++) val=FileReadNumber(handle);
   val=FileReadNumber(handle);
   Comment (val);
   FileClose(handle);
 
Petr Nosek:
I suppose you meant the fourth number in the row. First you have to read over the first three numbers and then the fourth one. If there is comma "," as a delimiter in your csv file you have to  declare it in FileOpen() because the default delimiter is semicolon.
Thanks a lot Sir, for explaining to me, it worked perfectly, have a great day