Fantastic! That’s a great bug to have worked out.
Instead of parsing the string character by character, what you should do now is use split() on each string. This should give you an array of strings, some of which may be empty.
For example,
String[] csv_data = loadStrings("file.csv");
for( ? ? ? ){ // For each line,
String[] line = csv_data.split(','); // Split it based on commas.
for( ? ? ? ){ // For each string in the line array,
if( line[?].charAt[0] == 'x' ){
level_data[?][?] = 1;
} /// etc
}
}
This will deal with the commas properly. You don’t want to just remove or ignore them, because two commas next to each other still has a meaning - that there is ground there!