Hey everyone,
First of all, I understand that it's unusual that I want to up-convert like this, but please bear with me. We get these csv files via website export and we have no options to get it in any other form.
Now, onto the question:
I have this old code that will do this process for me. It basically reads each line, then picks out each value between the ,
s. This worked great for some samples that I converted, but when it came down to working with the samples given, some values were out of place.
I opened the files in Notepad++ and realized that some of the cells, themselves, contained ,
s. CSV files work around this by surrounding these cells with "
s. See examples below:
.
This would work fine:
John,Smith,[email protected],burgers
This, however, would not:
John,Smith,[email protected],"burgers, french fries"
.
Unfortunately, my code (String strar[] = thisLine.split(",");
) doesn't take into account that some cells contain commas, and will separate them into different columns like: "burgers
and french fries"
.
.
How can I get my program to efficiently treat text surrounded by "
s as a single value, not two separate ones?
.
Let me know if I can clear anything else up for you guys.
Many thanks for the help,
Justian