79280811

Date: 2024-12-14 14:42:34
Score: 1
Natty:
Report link

One solution with pd.read_csv:

csv_content = """\
# title: Sample CSV
# description: This dataset
id,name,favourite_hashtag
1,John,#python
# another comment in the middle
2,Jane,#rstats
"""

data = pd.read_csv(io.StringIO(csv_content), header=2, on_bad_lines="skip")

And if you have comments in the middle of the file:

data = data[data.iloc[:, 0].str[0] != "#"]

res

Reasons:
  • Probably link only (1):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: rehaqds