Quantcast
Viewing all articles
Browse latest Browse all 14069

How to convert df to csv file using to_csv without quotation marks and messing with the content further?

I convert dfs to CSV file as folowing:

df_test.to_csv('path', sep=';', index=False, header=False)

The output rows in the file should be like this:

smiles;6

Instead:

"smiles;6"

Tried:

df_test.to_csv('path', sep=';', index=False, header=False, quoting=csv.QUOTE_NONE)

The error:

need to escape, but no escapechar set

Tried:

df_test.to_csv('path', sep=';', index=False, header=False, quoting=csv.QUOTE_NONE, escapechar=';')

The output:

smiles;;6

Tried:

df_test.to_csv('path', sep=';', index=False, header=False, quoting=csv.QUOTE_NONE, escapechar='\0')

The output:

smiles[nul];6

where [nul] is some kind of symbol that cannot the copied and pasted

The df_test dataframe after convertion looks like this:

"[F-].CCCCN+(CCCC)CCCC.CC(C)(C)Si(C)[O:24][CH2:25]C@@H:26[O:28][CH2:29]C@@H:30[O:42][c:43]1[c:44]2c:45n:49[n:50][cH:51]2>C1CCOC1>[OH:24][CH2:25]C@@H:26[O:28][CH2:29]C@@H:30[O:42][c:43]1[c:44]2c:45n:49[n:50][cH:51]2;6"

"Cl[c:2]1[c:3]2c:4[nH:8]c:9[cH:10]2.[NH:20]1[CH2:21][CH2:22][c:23]2[cH:24][cH:25][cH:26][cH:27][c:28]21>CCCCO>[c:2]1([N:20]2[CH2:21][CH2:22][c:23]3[cH:24][cH:25][cH:26][cH:27][c:28]32)[c:3]2c:4[nH:8]c:9[cH:10]2;1"

"[NH2:1][c:2]1[c:3]2n:4c:8[n:9][c:10]2-[c:11]1[cH:12][cH:13]c:14[cH:24][cH:25]1>CCCC#CC(=O)O>[NH2:1][c:2]1[c:3]2n:4c:8[n:9][c:10]2-[c:11]1[cH:12][cH:13]c:14[cH:24][cH:25]1;2"

"Br[c:2]1[cH:3]c:4c:5[cH:6][cH:7]1.Cc1ccccc1P(c1ccccc1C)c1ccccc1C.CCN(CC)CC.C:56(=[O:59])[O:60][CH3:61]>CC(=O)[O-].[Pd+2].CC(=O)[O-].O.CN(C)C=O>[c:2]1(/[CH:58]=[CH:57]/C:56[O:60][CH3:61])[cH:3]c:4c:5[cH:6][cH:7]1;3"

"Br[c:22]1[cH:21][n:20]c:19[cH:24][cH:23]1.CCNCC.[CH:36]1([C:39]#[CH:40])[CH2:37][CH2:38]1.Cc1ccccc1>CN(C)C=O.[Pd+4].c1ccc(P-c2ccccc2)cc1.c1ccc(P-c2ccccc2)cc1.c1ccc(P-c2ccccc2)cc1.c1ccc(P-c2ccccc2)cc1.[Cu+].[I-]>[NH2:1][C:2]1=[N:7]C@:6([c:10]2[cH:11]c:12[cH:13][cH:14][c:15]2[F:16])[CH2:5]C@@H:4[O:3]1;3"

All the rows are separated.


Viewing all articles
Browse latest Browse all 14069

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>