-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCopyWindFilesForState.py
More file actions
42 lines (35 loc) · 1.63 KB
/
CopyWindFilesForState.py
File metadata and controls
42 lines (35 loc) · 1.63 KB
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
#Michael Craig
#Nov 16, 2016
#Copy over NREL eastern wind dataset files to new location
#for given states.
from AuxFuncs import *
import os, copy, shutil
def keyParameters():
states = {'Texas'}
currDir = 'C:\\Users\\mtcraig\\Desktop\\EPP Research\\Databases\\Eastern Wind Dataset'
newDir = 'C:\\Users\\mtcraig\\Desktop\\EPP Research\\Databases\\Eastern Wind Dataset Texas'
if not os.path.exists(newDir): os.makedirs(newDir)
masterFile = 'eastern_wind_dataset_site_summary.csv'
return (states,currDir,newDir,masterFile)
def masterFunction():
(states,currDir,newDir,masterFile) = keyParameters()
(siteFilenames,newMasterList) = processMasterFile(currDir,states,masterFile)
for filename in siteFilenames:
shutil.copyfile(os.path.join(currDir,filename),os.path.join(newDir,filename))
write2dListToCSV(newMasterList,os.path.join(newDir,masterFile))
def processMasterFile(currDir,states,masterFile):
masterData = readCSVto2dList(os.path.join(currDir,masterFile))
siteCol, stateCol = masterData[0].index('SiteNumber'), masterData[0].index('State')
masterDataState = [copy.copy(masterData[0])]
siteFilenames = []
for row in masterData[1:]:
if row[stateCol] in states:
masterDataState.append(row)
siteFilenames.append(createSiteFilename(row[siteCol]))
return (siteFilenames,masterDataState)
#siteNum = str
def createSiteFilename(siteNum):
numDigitsInSiteFilenames = 5
numLeadingZerosNeeded = numDigitsInSiteFilenames - len(siteNum)
return 'SITE_' + '0' * numLeadingZerosNeeded + siteNum + '.csv'
masterFunction()