Go Down

Topic: Reading integers from SD card (Read 2 times) previous topic - next topic


Hi working on a program that needs to pull data from an SD card. The file is a .csv and i have 2 columns and multiple rows(about 400). The data is 4 or 5 digit numders eg 2568, 45876.
I have a counter in my program and want to pull the first row at say count 5, then at count 10 pull the second row and so on. Any tips on how to do this, I have seen examples of 1 column and 1 row but not multiple. I could separate the columns into 2 files if that makes it easier.

Thanks for your help


The arduino does not under stand file types, at all, or at least in any thing like the way a PC does. Windows associates a file type with a program and then calls then calls that program to deal with the file. I can't think what application a .cvs file is for.

But I would try this,

Export the file from the application (and I mean export not save) as a text file. You can the see the format of data in the file with notepad.

After that its not to hard ( :smiley-roll:) to read the data from the file.



You're going to need a state machine and basic string reading techniques to read in the values. Posting what code you have so far is going to make it a lot easier to help.


Your sketch will read the file as a sequence of characters and it will need to step through it looking for line separators until it gets to the line of interest, then step through the line looking for column separators (i.e. commas) until it gets to the field of interest, and then extract the characters containing the decimal digits and parse them to get the corresponding number.

If you can separate the columns into separate files (one column per file) that reduces the amount of work needed to parse the file contents.

Do you have any performance constraints for this - do you care how long it takes to read the values?
I only provide help via the forum - please do not contact me for private consultancy.


I am going to simplify the code and post it. As for speed it will need to be read in under  .1 second.

Thanks for the replies

Go Up