Open denis-bz opened 10 months ago
messier than I thought, try sep=r"\s+"
too
related: https://github.com/pandas-dev/pandas/issues/36069
Fwiw, a tiny testcase generator for this --
# 24 x 4 csv, permutations of A , \t #
# to test https://github.com/pandas-dev/pandas/issues/55916
from itertools import permutations
from io import StringIO
import pandas as pd
print( f"{pd.__version__ = }" ) # 2.1.3
rows = ["A,B"] + ["".join( p ) for p in permutations( "A,\t#" )]
csvstr = "\n".join( rows )
for engine in ["c", "python"]:
# for sep, for comment
print( f"\n-- {engine = }" )
df = pd.read_csv( StringIO( csvstr ), sep=",", comment="#", engine=engine,
skip_blank_lines=True, # default
)
print( df )
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
Issue Description
pd.version = '2.1.2'
-- engine = 'c' col1 col2 col3 0 1 4.4 99 1 \t NaN NaN 2 3 4.7 65
-- engine = 'python' col1 col2 col3 0 1 4.4 99 1 3 4.7 65
Expected Behavior
with
skip_blank_lines=True
, all engines should skip lines starting with whitespace commentcharInstalled Versions