Skip to content

Instantly share code, notes, and snippets.

@plablo09
Created June 2, 2016 18:50
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 plablo09/de671a93027137a3632d803d962545a1 to your computer and use it in GitHub Desktop.
Save plablo09/de671a93027137a3632d803d962545a1 to your computer and use it in GitHub Desktop.
Extract all shapes and import them to postgis
#!/usr/bin/python
# -*- coding: utf-8 -*-
import glob
import os
import zipfile
print 'hey'
w_dir = '/home/plablo/tmp_data/'
files = glob.glob(w_dir + '*.zip')
d_2015 = []
d_2016 = []
for f in files:
if len(f.split('.')[0].split('_')) == 4:
d_2015.append(f)
z_file = zipfile.ZipFile(f)
#print os.path.split(f)[1]
for name in z_file.namelist():
(dirname,filename) = os.path.split(name)
z_file.extract(name,w_dir + '/shapes_2015/')
else:
d_2016.append(f)
d_2015.append(f)
z_file = zipfile.ZipFile(f)
#print os.path.split(f)[1]
for name in z_file.namelist():
(dirname,filename) = os.path.split(name)
z_file.extract(name,w_dir + '/shapes_2016/')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment