-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
QST: CSV: export, import and new lines #36062
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
How about
? |
@MarcoGorelli , that's a synthetic example. Fact is:
|
Ah, I see. How about
then? |
@MarcoGorelli , ok, it works. But why
|
Sorry, ignore me, my answer doesn't make sense. I think @gfyoung would know about this |
add a In [1]: import pandas as pd
In [2]: df = pd.DataFrame([ ['a\rb'] ], columns=['A'])
In [3]: df.to_csv('df.csv', index=False, sep=';', encoding='utf-8', quoting=1)
In [4]: df_imported = pd.read_csv('df.csv', sep=';', encoding='utf-8')
In [5]: (len(df), len(df_imported))
Out[5]: (1, 1)
In [6]: df
Out[6]:
A
0 a\rb
In [7]: df_imported
Out[7]:
A
0 a\rb |
@MarcoGorelli , @asishm, well... First of all, thanks!
And |
Now exhaustively, thanks! |
I have searched the [pandas] tag on StackOverflow for similar questions.
I have asked my usage related question on StackOverflow.
Question about pandas
On Linux, symbol
\r
is not escaped bypd.to_csv
. But seems likepd.read_csv
expects something else.Is it bug or feature? How to avoid this?
The text was updated successfully, but these errors were encountered: