Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Support different delimiters for to_csv #244

Closed
wants to merge 3 commits into
from
Jump to file or symbol
Failed to load files and symbols.
+4 −2
Split
View
@@ -469,7 +469,7 @@ def to_sparse(self, fill_value=None, kind='block'):
default_fill_value=fill_value)
def to_csv(self, path, nanRep='', cols=None, header=True,
- index=True, index_label=None, mode='w'):
+ index=True, index_label=None, mode='w', delimiter=","):
"""
Write DataFrame to a comma-separated values (csv) file
@@ -489,9 +489,11 @@ def to_csv(self, path, nanRep='', cols=None, header=True,
`header` and `index` are True, then the index names are used. A
sequence should be given if the DataFrame uses MultiIndex.
mode : Python write mode, default 'w'
+ delimiter : character, default ","
+ Field delimiter for the output file.
"""
f = open(path, mode)
- csvout = csv.writer(f, lineterminator='\n')
+ csvout = csv.writer(f, lineterminator='\n', delimiter=delimiter)
if cols is None:
cols = self.columns