I have been trying to read an array of numbers in a "txt" file from a SD-card with the Sysfile library. The program seems to recognize the file and read some data. The problem is that the number of datapoints is off, and the values make no sense compared with the input file (2.52E-9 instead of the input 100.1).
The code i use is seen below.
The file contains an array of 10000 datapoint, and i have tried seperating the the datapoint by "," and "." and " ". I have also tried making it all in one column instead of a row. And i still can't get it to work
Thanks in advance
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
J think you can't read file in only one time.
You have to read number by number, until you reach the end of file.
Depending the way you used to write your file :
1Β°) If each number as the same format you can define what you want to read by the length of a number
2Β°) if you used a separation character, you can read character by character and concat characters into a string, until you reach the end of line or this special separating character.
3Β°) if you write your file with columns (Excel) you can read cell by cell, until you reach the end of the column or the end of line. And perhaps you need read character by character as in the second solution.
In all cases, don't forget to convert the string you read into numerical value.
BR
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have been trying to read an array of numbers in a "txt" file from a SD-card with the Sysfile library. The program seems to recognize the file and read some data. The problem is that the number of datapoints is off, and the values make no sense compared with the input file (2.52E-9 instead of the input 100.1).
The code i use is seen below.
The file contains an array of 10000 datapoint, and i have tried seperating the the datapoint by "," and "." and " ". I have also tried making it all in one column instead of a row. And i still can't get it to work
Thanks in advance
Hi,
J think you can't read file in only one time.
You have to read number by number, until you reach the end of file.
Depending the way you used to write your file :
1Β°) If each number as the same format you can define what you want to read by the length of a number
2Β°) if you used a separation character, you can read character by character and concat characters into a string, until you reach the end of line or this special separating character.
3Β°) if you write your file with columns (Excel) you can read cell by cell, until you reach the end of the column or the end of line. And perhaps you need read character by character as in the second solution.
In all cases, don't forget to convert the string you read into numerical value.
BR