numpy.loadtxt: how to ignore comma delimiters that appear inside quotes?
While there is not such a parameter in numpy.loadtxt to ignore quoted or otherwise escaped commas, one alternative that has not been suggested yet would be the following...
Perform a find and replace using some text editor to replace commas with tabs
OR
save the file in Excel as tab delimited.
When you use numpy.loadtxt, you will simply specify delimiter='\t' instead of comma delimited.
Simple solution that could save you some code...
I have a csv file where a line of data might look like this:
10,"Apple, Banana",20,...
When I load the data in Python, the extra comma inside the quotes shifts all my column indices around, so my data is no longer a consistent structure. While I could probably write a complex algorithm that iterates through each row and fixes the issue, I was hoping there was an elegant way to just pass an extra parameter to loadtxt (or some other function) that will properly ignore commas inside quotes and treat the entire quote as one value.
Note, when I load the CSV file into Excel, Excel correctly recognizes the string as one value.