Read-With-Unicode-Escape
Sat 17 May 2025
title: "Read Online CSV with Unicode Escape" author: "Raja CSP Raman" date: 2019-04-20 description: "-" type: technical_note draft: false
'''
https://stackoverflow.com/questions/22216076/unicodedecodeerror-utf8-codec-cant-decode-byte-0xa5-in-position-0-invalid-s
'''
'\nhttps://stackoverflow.com/questions/22216076/unicodedecodeerror-utf8-codec-cant-decode-byte-0xa5-in-position-0-invalid-s\n'
from io import BytesIO
import requests
import pandas as pd
filename = 'https://www.sample-videos.com/csv/Sample-Spreadsheet-10-rows.csv'
r = requests.get(filename)
data = r.content
df = pd.read_csv(BytesIO(data), index_col=0, encoding = 'unicode_escape')
df.head()
| Eldon Base for stackable storage shelf, platinum | Muhammed MacIntyre | 3 | -213.25 | 38.94 | 35 | Nunavut | Storage & Organization | 0.8 | |
|---|---|---|---|---|---|---|---|---|---|
| 1 | |||||||||
| 2 | 1.7 Cubic Foot Compact "Cube" Office Refrigera... | Barry French | 293 | 457.81 | 208.16 | 68.02 | Nunavut | Appliances | 0.58 |
| 3 | Cardinal Slant-D® Ring Binder, Heavy Gauge Vinyl | Barry French | 293 | 46.71 | 8.69 | 2.99 | Nunavut | Binders and Binder Accessories | 0.39 |
| 4 | R380 | Clay Rozendal | 483 | 1198.97 | 195.99 | 3.99 | Nunavut | Telephones and Communication | 0.58 |
| 5 | Holmes HEPA Air Purifier | Carlos Soltero | 515 | 30.94 | 21.78 | 5.94 | Nunavut | Appliances | 0.50 |
| 6 | G.E. Longer-Life Indoor Recessed Floodlight Bulbs | Carlos Soltero | 515 | 4.43 | 6.64 | 4.95 | Nunavut | Office Furnishings | 0.37 |
df.tail()
| Eldon Base for stackable storage shelf, platinum | Muhammed MacIntyre | 3 | -213.25 | 38.94 | 35 | Nunavut | Storage & Organization | 0.8 | |
|---|---|---|---|---|---|---|---|---|---|
| 1 | |||||||||
| 6 | G.E. Longer-Life Indoor Recessed Floodlight Bulbs | Carlos Soltero | 515 | 4.43 | 6.64 | 4.95 | Nunavut | Office Furnishings | 0.37 |
| 7 | Angle-D Binders with Locking Rings, Label Holders | Carl Jackson | 613 | -54.04 | 7.30 | 7.72 | Nunavut | Binders and Binder Accessories | 0.38 |
| 8 | SAFCO Mobile Desk Side File, Wire Frame | Carl Jackson | 613 | 127.70 | 42.76 | 6.22 | Nunavut | Storage & Organization | NaN |
| 9 | SAFCO Commercial Wire Shelving, Black | Monica Federle | 643 | -695.26 | 138.14 | 35.00 | Nunavut | Storage & Organization | NaN |
| 10 | Xerox 198 | Dorothy Badders | 678 | -226.36 | 4.98 | 8.33 | Nunavut | Paper | 0.38 |
Score: 5
Category: basics