(Python) Parsing tab delimited strings with newline characters -


i trying read file tab delimited fields may contain newline characters , maintain field has newlines. current implementation creates new fields each "\n".

i have tried csv module , splitting on "\t" no success on i'm looking for. following sample line given file:

*field_1 \t field_2 \t field_3 \n additional text \n more text \t field_4*

i generate list of 4 elements data above.

*["field_1", "field_2", "field3 \n additional text \n more text", "field_4"]*

any thoughts or suggestions helpful.

did try splitting on tab this?

data = 'field_1 \t field_2 \t field_3 \n additional text \n more text \t field_4' print data.split('\t') 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -