Arduino Stack Exchange is a question and answer site for developers of open-source hardware and software that is compatible with Arduino. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to read some database in text file. It's have a Code and respective number. This text file/database saved in an SD card. Code(UID) is 6bytes length array.number is integer type.

like this,

130,20,30,55,10,22\t128

20,10,20,30,55,68\t64

(\t = tab)

number of rows/lines can't be predicted.

Help to read this text file and extract one by one byte from it with respective number.

share|improve this question
    
What should we treat as a question ? 1) how to read text file from SD (library) or 2) how to parse such text file ? – soerium Oct 3 '15 at 18:17
    
@soerium on a machine with as tight a memory constraint the two are perhaps ideally not separated - ie, you don't read the file and then parse out the data, rather you identify the location of file data on the card and then read it byte by byte while making decisions as to what you want to keep, letting you use the SD card's SPI output block buffer rather than the Arduino's limited internal RAM to hold the yet-to-be-parsed data. – Chris Stratton Oct 3 '15 at 18:36
    
@ChrisStratton the OP mention that he "is trying" read the text file so I asked where he stuck. And yes, that's right - OP will need read the whole word (column) before convert the number (?) – soerium Oct 3 '15 at 18:56
    
Actually, no, they won't - converting characters one by one as they are read in over the SPI has the smallest memory footprint. Though if there's little else demanding resources, some buffering library approach can result in a shorter development time. – Chris Stratton Oct 3 '15 at 18:57
    
If the OP want convert such encoded integer (str) then he need converting characters one by one in a diffrent order they are stored in text file so he need read the word (column, to the semicolon or tab in this case) - for example: "20" = 0*10^0 + 2*10^1 – soerium Oct 3 '15 at 19:08

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.