Please does anyone have an idea on how to read data from a CSV file. I'm doing a datalogger project. I want to be able to write and also read the values in the CSV file I created.
The writing portion isn't an issue. I just need help with the reading aspect
How do you read this replay? One letter at a time. Your brain collects the letters into a record and parses the content. You have to do exactly the same thing.
While there is data in the file:
Read a character.
If it is not a carriage return or line feed:
Store the character in the next position in the array.
Increment the index to the next position.
Store a NULL in the next position in the array.
Else:
Parse the stored data.
Rest the index to 0.
Store a NULL at the index position in the array.
Parsing the data, using strtok() is simple. Converting a token to a number, using atoi() or atof() is simple.
It looks like you are only looking half-way down the path. What do you intend to do with the data once you have read it? More to the point, why are you doing the reading?