[英]"Error tokenizing data" when reading in a csv from a url in python using pandas
I am trying to read in a csv from a url ( csv link ) then isolate the ticker symbols (AMLP, ARKF, ARKG, ARKK, etc.), but I am running into a problem just reading in the csv.我正在尝试从 url( csv 链接)读取 csv,然后隔离股票代码(AMLP、ARKF、ARKG、ARKK 等),但我在读取 csv 时遇到了问题。
The exact error is: "pandas.errors.ParserError: Error tokenizing data. C error: Expected 8 fields in line 3, saw 12".确切的错误是:“pandas.errors.ParserError:错误标记数据。C 错误:预期第 3 行中有 8 个字段,看到 12”。
My code is as follows:我的代码如下:
import pandas as pd
df = pd.read_csv("https://www.cboe.com/available_weeklys/get_csv_download/")
print(df)
Try with:尝试:
df = pd.read_csv("https://www.cboe.com/available_weeklys/get_csv_download/", error_bad_lines=False)
If you just want to start from line 16 in the file (where AMLP is), use:如果您只想从文件中的第 16 行(AMLP 所在的位置)开始,请使用:
df = pd.read_csv("https://www.cboe.com/available_weeklys/get_csv_download/", skiprows=15, header=None)
>>> df
0 1
0 AMLP ALPS ETF TR ALERIAN MLP
1 ARKF ARK ETF TR FINTECH INNOVA
2 ARKG ARK ETF TR GENOMIC REV ETF
3 ARKK ARK ETF TR INNOVATION ETF
4 ASHR DBX ETF TR XTRACK HRVST CSI
.. ... ...
610 YY JOYY INC ADS REPSTG COM A
611 Z ZILLOW GROUP INC CL C CAP STK
612 ZM ZOOM VIDEO COMMUNICATIONS INC CL A
613 ZNGA ZYNGA INC CL A
614 ZS ZSCALER INC COM
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.