To save a csv file from pandas dataframe I have tried following way:
res.to_csv('seq_test.fa',header= False, index= False, sep = '\t', quoting = csv.QUOTE_NONE)
and this gives me following error:need to escape, but no escapechar set
If I don't use quoting = csv.QUOTE_NONE
. I get output below way:
>His-ATG-1-1 33-35
"TGGGGTATAGCTCCATGGTAGAGCGCATGCCTATGAAGCGTGAGGTCCTGGGTTTGATCCCCAGAACCACAACCA
"
>Pro-AGG-2-1 33-35
"GGCTTGTTGGTCTAGGGGTATGATTCTCACTTAGGGTGTGAGAGGTCCTGGGTTCAAATCTTGGACGAGTCCCCA
"
>Lys-TTT-1-1 34-36
"GCCCGGATAGCTCAGTCGGTAGAGCATCAGACTTTTAATCTGAGGGTCCAGGGTTCAAGTCCCTGTTCGGGCGCCA
"
>Ile-TAT-3-1 34-36
"GGTTCCATAGGGTAGTGGTTATCACATCTGCTTTATATGCAGAAGGTCCTGAGTTTGAGCCCCAGTGGAACTACCA
"
Here I don't want any double quotes in my output. Can someone suggest me any possible way? If anycase required I am using pandas version 0.17 on python 2.7
res.to_csv('seq_test.fa',header= False, index= False, sep = '\t', quoting = csv.QUOTE_NONE, escapechar = ' ')
Fill in the escapechar with whatever character is appropriate.
Reference: https://pandas.pydata.org/pandas-docs/version/0.17.0/generated/pandas.DataFrame.to_csv.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With