Skip to content

read_csv/to_csv sep/delimiter inconsistency #7662

Closed
@dsm054

Description

@dsm054

related #7615

Bit of a UI problem here (although it's behaving as the docstring says it does, so it doesn't quite qualify as a bug):

>>> df = pd.DataFrame({"A": [1,2,3], "B": [4,5,6]})
>>> df.to_csv("tmp.csv", sep=";")
>>> !cat tmp.csv
;A;B
0;1;4
1;2;5
2;3;6
>>> df.to_csv("tmp.csv", delimiter=";")
>>> !cat tmp.csv
,A,B
0,1,4
1,2,5
2,3,6

read_csv accepts both sep and delimiter but to_csv silently ignores delimiter. Someone was recently tripped up by this on SO. I'm fine with either teaching to_csv to behave the same way read_csv does or, alternatively, raising if delimiter is found as a keyword.

That is, I'm less bothered by the inconsistency than the silent unexpected behaviour.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions