I am parsing comma-delimited files with Python where some of the text fields are double-delimited with quotes because the text contains non-delimiting commas. For example, given this line of input:
field_1,field_2,...,"this,field,contains,non-delimiting,commas",...,field_n
I need to treat "this,field,contains,non-delimiting,commas"
as a single quote-delimited field containing pesky commas.
My code handles this by comparing the indices of all commas and quotes in each line of input and slicing the line at the indices of all commas outside of paired quotes.
This strikes me as un-Pythonic, though, and I am hoping to get some to get suggestions for a more Pythonic solution.