Skip to content

Instantly share code, notes, and snippets.

@aaronlelevier
Created March 30, 2015 22:16
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 aaronlelevier/202871d21afeddc823cd to your computer and use it in GitHub Desktop.
Save aaronlelevier/202871d21afeddc823cd to your computer and use it in GitHub Desktop.
Split a list using python and reformat it in a single column fomat
'''
To convert zipcodes
-------------------
From the output on: http://www.freemaptools.com/find-zip-codes-inside-radius.htm
to a list of strings to use as a filter in SQL.
Change data initially in this format:
1111,2222,3333
To this format:
,'1111'
,'2222'
,'3333'
'''
with open('scottsdale_new.txt', 'w') as n:
with open('scottsdale.txt', 'r') as f:
for line in f:
zips = line.split(",")
for z in zips:
n.write(",'"+z+"'\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment