Pandas version checks

  • [X] I have checked that this issue has not already been reported.

  • [X] I have confirmed this bug exists on the latest version of pandas.

  • [X] I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

import pandas as pd

"""
data contains only one line as below
"\""\t"a" (where "\t" is an escape character)
"""

df = pd.read_csv(data, sep='\t', header=None)

Issue Description

df will only have one column, which is expected to be two

Expected Behavior

separate it to two lines as we operate in following steps:

line = open(data).read() line.split("\t") # get two items

Installed Versions

INSTALLED VERSIONS ------------------ commit : d9cdd2ee5a58015ef6f4d15c7226110c9aab8140 python : 3.11.5.final.0 python-bits : 64 OS : Linux OS-release : 4.15.0-192-generic Version : #203-Ubuntu SMP Wed Aug 10 17:40:03 UTC 2022 machine : x86_64 processor : x86_64 byteorder : little LC_ALL : None LANG : en_US.UTF-8 LOCALE : en_US.UTF-8 pandas : 2.2.2 numpy : 1.24.3 pytz : 2023.3.post1 dateutil : 2.8.2 setuptools : 68.0.0 pip : 23.2.1 Cython : None pytest : 7.4.0 hypothesis : None sphinx : 5.0.2 blosc : None feather : None xlsxwriter : None lxml.etree : 4.9.3 html5lib : None pymysql : None psycopg2 : None jinja2 : 3.1.2 IPython : 8.15.0 pandas_datareader : None adbc-driver-postgresql: None adbc-driver-sqlite : None bs4 : 4.12.2 bottleneck : None dataframe-api-compat : None fastparquet : None fsspec : 2023.4.0 gcsfs : None matplotlib : 3.7.2 numba : 0.57.1 numexpr : 2.8.4 odfpy : None openpyxl : None pandas_gbq : None pyarrow : 11.0.0 pyreadstat : None python-calamine : None pyxlsb : None s3fs : 2023.4.0 scipy : 1.11.1 sqlalchemy : None tables : 3.8.0 tabulate : None xarray : 2023.6.0 xlrd : None zstandard : 0.19.0 tzdata : 2023.3 qtpy : None pyqt5 : None

Comment From: Anurag-Varma

The data line which you gave is "\""\t"a"

But the image in issue description has different text.

Can you give exactly what should be present, and here does data mean its a path to a .csv file, cause you didn't describe the issue properly ?

Comment From: hyleepp

I’m sorry for my unclear expression.

  1. The actual data is still "\""\t"a" like the below image. The image in the first comment is meant to show that pd does not separated into two elements as expected.
  2. Yes, data means a path to a .csv file that contains the given line.

Comment From: Anurag-Varma

This works when you have the data inside .csv to be in the format of: "\"" "a"

But fails for "\""\t"a"

I think using the separator \t checks for tab spaces and not for the same exact \t separator

Comment From: Anurag-Varma

@hyleepp

Or else you can use :

import pandas as pd

# Specify the path to your CSV file
file_path = 'test.csv'

# Read the file using tab as the separator
df = pd.read_csv(file_path, delimiter='t', header=None, escapechar='\\')

# Display the dataframe
print(df)

Output:

    0  1
0  "\  a

Comment From: Anurag-Varma

take

Comment From: Anurag-Varma

Hi @hyleepp if the issue is solved can you close the issue ?

If u think there is a bug, you can keep it open.

Thanks