-
Notifications
You must be signed in to change notification settings - Fork 0
lbCSV
#Lunchbox - lbCSV# Jump to lbCSV Code
- Download the repo to your project, and include it. See install details for more.
- Use an instance of lbCSV to load your file with
read()
. - Access your data with
yourinstance.data[row][col_name]
Note: At its current stage, lbCSV relies on lbLog to log any errors, and will crash without it. As long as you include the entire repo, and don't move things around, it should be all good though.
For a working example, see here.
#####CSV Format#### lbCSV reads any text file, and will assume it's in standard CSV format. If there is an error with any of the formatting, you will be given everything up to the error. For an example of a valid CSV file for lbCSV, see here. Anything after a '#' will be ignored until the end of the line. You can escape any #'s or commas by surrounding them with quotes. Eg:
# This is a comment line
value1,value2,value3 # The values will still be read, but this won't be.
value1,"value2,value2.5",value3 # There is still only 3 values on this line
###Documentation### TABLE is a typedef of vector< map <string, string> >
#####void read(string fileName)
#####
Reads and loads the data of a given file. Note this can also be done in the constructor like lbCSV list(fileName);
.
-
fileName
: name of file. This should include the path (relative from where the executable is) to the CSV, and the extension. eg:"lists/mcu_list.txt"
.
That's it! Super simple stuff.
The lunchbox toolbox. (c) Samuel Lewis 2015.