[英]How to read a csv file using pandas in Python?
I'm trying to read the following csv file https://storage.googleapis.com/play_public/supported_devices.csv using pandas:
android_data = pandas.read_csv("https://storage.googleapis.com/play_public/supported_devices.csv", sep = "delimiter", encoding = "ISO-8859-1", engine = "python")
print(android_data.head(10))
但该文件没有解析好,这意味着 dataframe 包含以下数据:
ÿþRetail Branding,Marketing Name,Device,Model
0
1 ,,AD681H,Smartfren Andr...
2
3 ,,FJL21,FJL21
4
5 ,,hws7721g,MediaPad 7 Y...
6
7 1&1,1&1 Puck,diw362_1u1...
8
9 1&1,1&1 TV Box,diw387_1...
为什么偶数行是空的,为什么每个奇数行都包含“零售品牌”列下的所有行数据?
该文件实际上编码为 UTF-16LE, sep
应该是","
,而不是"delimiter"
。 以下对我有用:
url = "https://storage.googleapis.com/play_public/supported_devices.csv"
android_data = pandas.read_csv(url, sep=",", encoding="UTF-16LE", engine="c")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.