Skip to content

Instantly share code, notes, and snippets.

@yosemitebandit
Created February 26, 2015 18:04
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 yosemitebandit/4e9609e22122362e2524 to your computer and use it in GitHub Desktop.
Save yosemitebandit/4e9609e22122362e2524 to your computer and use it in GitHub Desktop.
decode and resave urlencoded files
import sys
import urllib
# Read.
with open(sys.argv[1]) as cdr_file:
cdr_data = cdr_file.read()
# Decode.
decoded_data = urllib.unquote(cdr_data).decode('utf8')
print decoded_data
# Write.
new_filename = '%s.decoded' % sys.argv[1]
with open(new_filename, 'w') as decoded_file:
decoded_file.write(decoded_data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment