-
Notifications
You must be signed in to change notification settings - Fork 15
/
HYDRAID_to_HEC-RAS.py
53 lines (40 loc) · 1.19 KB
/
HYDRAID_to_HEC-RAS.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# -*- coding: utf-8 -*-
"""
This script takes all the *.zip files from a folder (ras_zip_folder) and makes
a table of HYDRAIDs and rasfiles and extracts all the contents of the .zip files
to a location (ras_zip_folder) - in this case the parent folder.
Created on Sun Jun 14 02:56:32 2015
@author: Solo
"""
# Changeables
#ras_zip_folder = r'C:\Users\Solo\Dropbox\Python\HEC-RAS_Models' ### Test case Tar
ras_zip_folder = r'C:\Users\Solo\Dropbox\EEP\Beaufort' ### Test case Catawba (9 minutes))
# Rest
import glob
import os
import tempfile
import zipfile
os.chdir(ras_zip_folder)
os.getcwd()
filenames = glob.glob("*.zip")
rasfiles = []
HYDRAIDs = []
for filename in filenames:
temp = tempfile.mkdtemp()
with zipfile.ZipFile(filename, "r") as z:
z.extractall(temp)
#z.extractall(ras_zip_folder)
print temp
os.chdir(temp)
rasfile = glob.glob("*.prj")
HYDRAID = filename[:filename.find('_')]
os.chdir(ras_zip_folder)
HYDRAIDs.append(HYDRAID)
rasfiles.append(rasfile)
table = zip(HYDRAIDs, rasfiles)
###
'''if '\\' in filename:
fname = fname.replace('\\', '/')
return fname'''
#
# C:\Users\Solo\Dropbox\Python\HEC-RAS_Model