Giulio Carotta
Giulio Carotta

Reputation: 1

Opening txt data files from url in Python

I'm trying to open some data from a URL but it gives me problems and errors I don't know how to deal with. My goal is to get two arrays of data, one for time input and another for some kind of variable. This is what I've tried:

url = "https://github.com/giulio99/Relazione-FFT/blob/master/dati%20giulio/datilunghiquad_b.txt"
df = pd.read_csv(url, sep="\t")

df.columns =['time', 'voltage']

t1 = list(df.time)

V1 = list(df.voltage) 

The error that I get is

pandas.errors.ParserError: Error tokenizing data. C error: Expected 1 fields in line 823, saw 2

Can someone help me?

Upvotes: 0

Views: 31

Answers (1)

Nullman
Nullman

Reputation: 4279

you are downloading the wrong file! you want the raw file, not the html page.
notice the raw button on that page, it will gives you the address:
https://raw.githubusercontent.com/giulio99/Relazione-FFT/master/dati%20giulio/datilunghiquad_b.txt

Upvotes: 1

Related Questions