You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importsysifsys.version_info[0] <3:
fromStringIOimportStringIOelse:
fromioimportStringIOimportpandasaspdimportcsvescape_char_defined='\\'quote_defined='"'separator="|"sample_data= []
foriinrange(1,11):
sample_data.append(i*escape_char_defined+quote_defined)
initial_df=pd.DataFrame(sample_data,columns=['column'])
csv_text=initial_df.to_csv(sep=separator,columns=None,header=None,index=False,doublequote=False,quoting=csv.QUOTE_ALL,quotechar=quote_defined,escapechar=escape_char_defined,encoding='utf-8')
csv_text=StringIO(csv_text)
final_df=pd.read_csv(csv_text,sep=separator,escapechar=escape_char_defined,quoting=csv.QUOTE_ALL,header=None,doublequote=False,encoding='utf-8')
ifnotfinal_df.equals(initial_df):
raiseException("Dataframes are not equal!")
Problem description
When defining several strings with an escape char before the quotechar, the same CSV generated by pandas is not read properly when transforming back to a pandas dataframe.
Expected Output
The dataframe written should be equal to the dataframe read.
Output of pd.show_versions()
INSTALLED VERSIONS
commit: None
python: 3.6.4.final.0
python-bits: 64
OS: Windows
OS-release: 10
machine: AMD64
processor: Intel64 Family 6 Model 85 Stepping 4, GenuineIntel
byteorder: little
LC_ALL: None
LANG: en
LOCALE: None.None
Code Sample, a copy-pastable example if possible
Problem description
When defining several strings with an escape char before the quotechar, the same CSV generated by pandas is not read properly when transforming back to a pandas dataframe.
Expected Output
The dataframe written should be equal to the dataframe read.
Output of
pd.show_versions()
INSTALLED VERSIONS
commit: None
python: 3.6.4.final.0
python-bits: 64
OS: Windows
OS-release: 10
machine: AMD64
processor: Intel64 Family 6 Model 85 Stepping 4, GenuineIntel
byteorder: little
LC_ALL: None
LANG: en
LOCALE: None.None
pandas: 0.24.1
pytest: 3.3.2
pip: 9.0.1
setuptools: 38.4.0
Cython: 0.27.3
numpy: 1.14.0
scipy: 1.0.0
pyarrow: None
xarray: None
IPython: 6.2.1
sphinx: 1.6.6
patsy: 0.5.0
dateutil: 2.6.1
pytz: 2017.3
blosc: None
bottleneck: 1.2.1
tables: 3.4.2
numexpr: 2.6.4
feather: None
matplotlib: 2.1.2
openpyxl: 2.5.12
xlrd: 1.1.0
xlwt: 1.3.0
xlsxwriter: 1.0.2
lxml.etree: 4.1.1
bs4: 4.6.0
html5lib: 1.0.1
sqlalchemy: 1.1.18
pymysql: None
psycopg2: None
jinja2: 2.8.1
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
gcsfs: None
The text was updated successfully, but these errors were encountered: