Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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))

but the file is not parsed well, meaning the dataframe contains the following data:

   ÿþ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...  

Why there are the even lines empty and why each odd line contains all row data under "Retail Branding" column?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

The file is actually encoded as UTF-16LE, and sep should be ",", not "delimiter". The following worked for me:

url = "https://storage.googleapis.com/play_public/supported_devices.csv"
android_data = pandas.read_csv(url, sep=",", encoding="UTF-16LE", engine="c")
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading