Skip to content

Instantly share code, notes, and snippets.

@wesm
Created December 11, 2012 17:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wesm/4260416 to your computer and use it in GitHub Desktop.
Save wesm/4260416 to your computer and use it in GitHub Desktop.
Parsing escapes
In [15]: paste
data = '''SEARCH_TERM,ACTUAL_URL
"bra tv bord","http://www.ikea.com/se/sv/catalog/categories/departments/living_room/10475/?se%7cps%7cnonbranded%7cvardagsrum%7cgoogle%7ctv_bord"
"tv p\xc3\xa5 hjul","http://www.ikea.com/se/sv/catalog/categories/departments/living_room/10475/?se%7cps%7cnonbranded%7cvardagsrum%7cgoogle%7ctv_bord"
"SLAGBORD, \\"Bergslagen\\", IKEA:s 1700-tals serie","http://www.ikea.com/se/sv/catalog/categories/departments/living_room/10475/?se%7cps%7cnonbranded%7cvardagsrum%7cgoogle%7ctv_bord"'''
df = read_csv(StringIO(data), escapechar='\\', encoding='utf-8')
## -- End pasted text --
In [16]: df
Out[16]:
SEARCH_TERM ACTUAL_URL
0 bra tv bord http://www.ikea.com/se/sv/catalog/categories/d...
1 tv på hjul http://www.ikea.com/se/sv/catalog/categories/d...
2 SLAGBORD, "Bergslagen", IKEA:s 1700-tals serie http://www.ikea.com/se/sv/catalog/categories/d...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment