mardi 31 mars 2015

python csv reader ignore commas within brackets

I have comma separated values that contain commas within nested brackets. Specifically, I'll have an input of comma separated C++11 objects (correct commas starred for emphases):



std::vector<int>{32, 45, 10} *,*
std::array<std::string, 5>{"a", "bc", "def", "ghij", "whoa, this is, a toughie"} *,*
8 *,*
"foo, bar" *,*
{"initializer-list?", "no problem!", "(hopefully...)"


But python's csv gives me:



[
'std::vector<int>{32',
'45',
'10}',
'std::array<std::string',
'5>{"a"',
'"bc"',
'"def"',
'"ghij"',
'"whoa',
'this is',
'a toughie"}',
'8',
'"foo',
'bar"',
'{"initializer-list?"',
'"no problem!"',
'"(hopefully...)"}'
]


How can I customize the csv module to handle these cases?


Aucun commentaire:

Enregistrer un commentaire