1

The datafile in the format of .csv can successfully readed in the local computer.

df = pd.read_csv("./data.csv") 

enter image description here

The file is upload here.

However, I use two method with the uploading data in Dropbox or Github, the reading process all occured error as follows:

df = pd.read_csv("https://www.dropbox.com/s/2ew62yi0v07tjub/data-1.csv?dl=0")     

error: pandas/parser.pyx in pandas.parser.TextReader.read (pandas/parser.c:10364)() pandas/parser.pyx in pandas.parser.TextReader._read_low_memory (pandas/parser.c:10640)() pandas/parser.pyx in pandas.parser.TextReader._read_rows (pandas/parser.c:11386)() pandas/parser.pyx in pandas.parser.TextReader._tokenize_rows (pandas/parser.c:11257)() pandas/parser.pyx in pandas.parser.raise_parser_error (pandas/parser.c:26979)() CParserError: Error tokenizing data. C error: Expected 1 fields in line 3, saw 2

df = pd.read_csv("https://github.com/envhyf/Notebook/blob/master/data-1.csv")  

CParserError: Error tokenizing data. C error: Expected 1 fields in line 116, saw 3

Thus, my question is why the csv file can be read in my own computer, but failed in the cloud?

How to fix this problem. I have tried the answer of this question by adding error_bad_lines=False. But it didn't work for me.

1 Answer 1

1

For github you can use raw data:

df = pd.read_csv("https://raw.githubusercontent.com/envhyf/Notebook/master/data-1.csv")

And for dropbox need dl=1, info from this:

df = pd.read_csv("https://www.dropbox.com/s/gcn75c65222dtfk/data-1.csv?dl=1")
Sign up to request clarification or add additional context in comments.

7 Comments

Thanks for your answer! I have tried and successfully read my datafile.
Thus, I suspected that the original url (e.g., github.com/xxx) is not supported for directly reading for pandas?
OK. Thanks for your carefully comments.
If it is 0 it return html page, see this - dropbox.com/help/desktop-web/force-download
Thanks! I understand.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.