Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import arcpy, os
- months = {'JAN':1,'FEB':2,'MAR':3,'APR':4,'MAY':5,'JUN':6,'JUL':7,'AUG':8,
- 'SEP':9,'OCT':10,'NOV':11,'DEC':12}
- ignore = ['Arbitrary_count','TOTAL_MGY','JAN','FEB','MAR','APR','MAY','JUN','JUL','AUG','SEP','OCT','NOV','DEC']
- ws = r'D:DataUsersjbellinoProjectfaswamdatawater_useSCFromTomAbSC_WELLS_data_jcb.mdb'
- arcpy.env.workspace = ws
- arcpy.env.overwriteOutput = True
- tbl = 'ORIGINAL_DHEC_WELL DATA'
- itbl = 'monthly_dhec_well_data'
- fields = arcpy.ListFields(tbl)
- rows = arcpy.SearchCursor(os.path.join(ws,tbl))
- irows = arcpy.InsertCursor(os.path.join(ws,itbl))
- for row in rows:
- for month in months:
- #--for each row in the original table, and for each month stored in that row,
- # create a new record in 'itbl'
- irow = irows.newRow()
- for field in fields:
- if field.name == month:
- #--if the field name refers to a month abbreviation it contains data
- # first convert the month abbreviation to month number
- irow.cn_mo = months[month]
- try:
- # then grab the data in the field and process it into the appropriate
- # fields of the new table in the correct units
- irow.cn_qnty_mo_va = row.getValue(field.name)*1000000
- irow.cn_qnty_mo_va_mega = row.getValue(field.name)
- except:
- #--skip null values
- pass
- elif field.name not in ignore:
- #--if the field name is not a month abbreviation, just copy the data
- # to the new table
- irow.setValue(field.name,row.getValue(field.name))
- irows.insertRow(irow)
- del irows
- import arcpy, os
- months = {'JAN':1,'FEB':2,'MAR':3,'APR':4,'MAY':5,'JUN':6,'JUL':7,'AUG':8,
- 'SEP':9,'OCT':10,'NOV':11,'DEC':12}
- ignore = ['Arbitrary_count','TOTAL_MGY','JAN','FEB','MAR','APR','MAY','JUN','JUL','AUG','SEP','OCT','NOV','DEC']
- ws = r'D:DataUsersjbellinoProjectfaswamdatawater_useSCFromTomAbSC_WELLS_data_jcb.mdb'
- arcpy.env.workspace = ws
- arcpy.env.overwriteOutput = True
- tbl = 'ORIGINAL_DHEC_WELL DATA'
- itbl = 'monthly_dhec_well_data'
- fields = arcpy.ListFields(tbl)
- rows = arcpy.SearchCursor(os.path.join(ws,tbl))
- irows = arcpy.InsertCursor(os.path.join(ws,itbl))
- for row in rows:
- for month in months:
- #--for each row in the original table, and for each month stored in that row,
- # create a new record in 'itbl'
- irow = irows.newRow()
- for field in fields:
- if field.name == month:
- #--if the field name refers to a month abbreviation it contains data
- # first convert the month abbreviation to month number
- irow.cn_mo = months[month]
- try:
- # then grab the data in the field and process it into the appropriate
- # fields of the new table in the correct units
- irow.cn_qnty_mo_va = row.getValue(field.name)*1000000
- irow.cn_qnty_mo_va_mega = row.getValue(field.name)
- except:
- #--skip null values
- pass
- elif field.name not in ignore:
- #--if the field name is not a month abbreviation, just copy the data
- # to the new table
- irow.setValue(field.name,row.getValue(field.name))
- irows.insertRow(irow)
- del irow,irows
- del row,rows
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement