Https://jovian.ai/madhu-712/explore-starbucks-worldwide-stores

Hi guys,

I am trying to run a notebook on binder.

Link :madhu-712/explore-starbucks-worldwide-stores - Jovian

I am trying to read this file by 2 methods

1.with open(‘work/directory.csv’) as file:
df=pd.read_csv(‘directory.csv’)

  1. Urllib.request method

url = ‘https://github.com/Madhu-712/sharing-github/blob/a996810c146c743cfdd889c4fa980d4890e1f3cd/directory.csv

urlretrieve(url,‘directory.csv’)

I got’ parser error’ in both the cases.

So, I added a separator in my code.

df = pd.read_csv(‘directory.csv’,sep=’|’)

0 <html lang=“en” data-color-mode=“auto” data-li…
1
2
3 <link rel=“dns-prefetch” href="https://githu
4 <link rel=“dns-prefetch” href="https://avata
966
967

As per my understanding, the problem is with csv file format.

How could I go about debugging this code.

Help on this would be very valuable.

Regards
Madhu

Are you sure you did download the CSV file, not an HTML page?

Hi Sebastian,

Yup. I Am quite sure about it and even double checked in binder under Menu>file>open section. The file was an.csv extension .

PS: Attaching the file for reference.

I tried importing this file through opendataset library .

This dataset was from kaggle and I downloaded kaggle .json file .

But, it failed to fetch my key details. Hence, couldn’t open the file for me.

It would be gr8 if you render help on this aswell.

Regards
Madhu…

If you did download it with urllib with such github URL , then I suspect you did download the HTML page and just named it directory.csv. This doesn’t make it a CSV file sadly :stuck_out_tongue:

You need an URL which contains only a CSV file and nothing else. Visiting such URL would cause your browser to ask you if you want to download this file.

If you want to download from github then you might try the raw file/download link, but I doubt this will work. The best option is to download the file and just add it manually to the notebook.

Never used opendatasets that much but I think it was mainly for downloading kaggle datasets. Although I think I saw someone using it with files from google drive (not sure).

Since this file isn’t that big I would suggest going the manual way for now. I’ll try investigate a bit further after work and check if od allows downloading such files.

I tried read this file thru urllib option and I haven’t renamed this to .csv extension by any chance.

I got a parser error .

Then, I tried to add the file manually on to binder and read it thru ‘with open’ command.

Code:

with open(‘work/directory.csv’) as file:
df=pd.read_csv(‘directory.csv’)

Even , in this case I get the same ‘parser error’.

So, I changed my code a bit by adding delimiter/separator.

Code:

So, I added a separator in my code.

df = pd.read_csv(‘directory.csv’,sep=’|’).

It’s no ‘hit’ even by manual method :frowning:

How did you download the file?
If you acquired it first with urllib and now you’re using it hoping it will work, then sadly not :stuck_out_tongue:
If you downloaded it manually (clicking download button) then it should be ok.

Hey Hi,

Yup, did a manual download and it worked…

Thanks,
Madhu…