-1

I am attempting to read the following csv so I can process it further but I am getting an pandas.errors.ParserError. I would really appreciate any help on how I can read it. Can you help me identify what I am doing wrong?

My code:

import pandas as pd
logic_df = pd.read_csv("http://www.sharecsv.com/s/6c1b912f54d87d45f4728f8fb1510a5eb/random.csv")

I am not sure if there is something wrong with my csv because I used csv lint and it said my csv is fine so I am not sure what the issue is.

I also tried to do the following

logic_df = pd.read_csv("http://www.sharecsv.com/s/6cb912f54d87d45f4728f81fb1510a5eb/random.csv", error_bad_lines=False)

with no luck.

Dinero
  • 1,070
  • 2
  • 19
  • 44

1 Answers1

1

Changing the url to the direct link of the table should work:

df = pd.read_csv("http://www.sharecsv.com/dl/6cb912f54d87d45f4728f8fb1510a5eb/random.csv")

The thing is, your url is pointing to a html page, not a csv file per se. You can either use the url above, or reading the your url source with pd.read_html, like this:

df = pd.read_html('http://www.sharecsv.com/s/6cb912f54d87d45f4728f8fb1510a5eb/random.csv', header=0)[0]

Hope it helps!

Cainã Max Couto-Silva
  • 4,839
  • 1
  • 11
  • 35
  • 1
    It's amazing what two letters can do. – BigBen Nov 18 '20 at 03:37
  • I have no access to such file (it's not public). Furthermore, if you want to read a google sheet file, it's another issue. Please take a look at: [Google Sheets API for Python](https://developers.google.com/sheets/api/quickstart/python) or any other tutorial about it. If you decides to make your url public, then go to [this answer](https://stackoverflow.com/a/55720172/7076819) from SO. It shows how to get the data from a public google sheet as csv. – Cainã Max Couto-Silva Nov 18 '20 at 04:02