I want to read from a stream and put the data in an (2D)array. The file I'm reading is a CSV-file like the following:
0.1;12345;98
0.2;5006;52
0.3;4540;38
So with every ';' it has to skip column and with every '\n' it has to skip a row. The file is opened through a fileDialogBox.
Can someone give me some advice on how to handle this problem?
See code below.
c is an int right now and you're calling the get char function to load it? I think you want a char for the semicolon. If you know the format I'd just load in the whole line then do the operations on it.
You can do it simply (although a lil ugly) by pulling in the float, then semicolon, then int, then semicolon, then int again and placing those into the array where you want them. Then just repeat this process until EOF.
Personally, I'd use the getline() function to read line-by-line from your file into a string. Then you can use string.find() and string.substring() to split the string up based on the location of the ","s