@@ -1305,7 +1305,7 @@ def _helper_csv(self, writer, na_rep=None, cols=None,
1305
1305
1306
1306
def to_csv (self , path_or_buf , sep = "," , na_rep = '' , float_format = None ,
1307
1307
cols = None , header = True , index = True , index_label = None ,
1308
- mode = 'w' , nanRep = None , encoding = None , quoting = None ):
1308
+ mode = 'w' , nanRep = None , encoding = None , quoting = None , line_terminator = ' \n ' ):
1309
1309
"""
1310
1310
Write DataFrame to a comma-separated values (csv) file
1311
1311
@@ -1336,6 +1336,8 @@ def to_csv(self, path_or_buf, sep=",", na_rep='', float_format=None,
1336
1336
encoding : string, optional
1337
1337
a string representing the encoding to use if the contents are
1338
1338
non-ascii, for python versions prior to 3
1339
+ line_terminator: string, default '\n '
1340
+ The newline character or character sequence to use in the output file
1339
1341
"""
1340
1342
if nanRep is not None : # pragma: no cover
1341
1343
import warnings
@@ -1355,11 +1357,11 @@ def to_csv(self, path_or_buf, sep=",", na_rep='', float_format=None,
1355
1357
1356
1358
try :
1357
1359
if encoding is not None :
1358
- csvout = com .UnicodeWriter (f , lineterminator = ' \n ' ,
1360
+ csvout = com .UnicodeWriter (f , lineterminator = line_terminator ,
1359
1361
delimiter = sep , encoding = encoding ,
1360
1362
quoting = quoting )
1361
1363
else :
1362
- csvout = csv .writer (f , lineterminator = ' \n ' , delimiter = sep ,
1364
+ csvout = csv .writer (f , lineterminator = line_terminator , delimiter = sep ,
1363
1365
quoting = quoting )
1364
1366
self ._helper_csv (csvout , na_rep = na_rep ,
1365
1367
float_format = float_format , cols = cols ,
0 commit comments