Advertisement
Guest User

Untitled

a guest
Jan 16th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.42 KB | None | 0 0
  1. import arcpy, os
  2.  
  3. months = {'JAN':1,'FEB':2,'MAR':3,'APR':4,'MAY':5,'JUN':6,'JUL':7,'AUG':8,
  4. 'SEP':9,'OCT':10,'NOV':11,'DEC':12}
  5. ignore = ['Arbitrary_count','TOTAL_MGY','JAN','FEB','MAR','APR','MAY','JUN','JUL','AUG','SEP','OCT','NOV','DEC']
  6.  
  7. ws = r'D:DataUsersjbellinoProjectfaswamdatawater_useSCFromTomAbSC_WELLS_data_jcb.mdb'
  8. arcpy.env.workspace = ws
  9. arcpy.env.overwriteOutput = True
  10. tbl = 'ORIGINAL_DHEC_WELL DATA'
  11. itbl = 'monthly_dhec_well_data'
  12.  
  13. fields = arcpy.ListFields(tbl)
  14.  
  15. rows = arcpy.SearchCursor(os.path.join(ws,tbl))
  16. irows = arcpy.InsertCursor(os.path.join(ws,itbl))
  17. for row in rows:
  18. for month in months:
  19. #--for each row in the original table, and for each month stored in that row,
  20. # create a new record in 'itbl'
  21. irow = irows.newRow()
  22. for field in fields:
  23. if field.name == month:
  24. #--if the field name refers to a month abbreviation it contains data
  25. # first convert the month abbreviation to month number
  26. irow.cn_mo = months[month]
  27. try:
  28. # then grab the data in the field and process it into the appropriate
  29. # fields of the new table in the correct units
  30. irow.cn_qnty_mo_va = row.getValue(field.name)*1000000
  31. irow.cn_qnty_mo_va_mega = row.getValue(field.name)
  32. except:
  33. #--skip null values
  34. pass
  35. elif field.name not in ignore:
  36. #--if the field name is not a month abbreviation, just copy the data
  37. # to the new table
  38. irow.setValue(field.name,row.getValue(field.name))
  39. irows.insertRow(irow)
  40. del irows
  41.  
  42. import arcpy, os
  43.  
  44. months = {'JAN':1,'FEB':2,'MAR':3,'APR':4,'MAY':5,'JUN':6,'JUL':7,'AUG':8,
  45. 'SEP':9,'OCT':10,'NOV':11,'DEC':12}
  46. ignore = ['Arbitrary_count','TOTAL_MGY','JAN','FEB','MAR','APR','MAY','JUN','JUL','AUG','SEP','OCT','NOV','DEC']
  47.  
  48. ws = r'D:DataUsersjbellinoProjectfaswamdatawater_useSCFromTomAbSC_WELLS_data_jcb.mdb'
  49. arcpy.env.workspace = ws
  50. arcpy.env.overwriteOutput = True
  51. tbl = 'ORIGINAL_DHEC_WELL DATA'
  52. itbl = 'monthly_dhec_well_data'
  53.  
  54. fields = arcpy.ListFields(tbl)
  55.  
  56. rows = arcpy.SearchCursor(os.path.join(ws,tbl))
  57. irows = arcpy.InsertCursor(os.path.join(ws,itbl))
  58. for row in rows:
  59. for month in months:
  60. #--for each row in the original table, and for each month stored in that row,
  61. # create a new record in 'itbl'
  62. irow = irows.newRow()
  63. for field in fields:
  64. if field.name == month:
  65. #--if the field name refers to a month abbreviation it contains data
  66. # first convert the month abbreviation to month number
  67. irow.cn_mo = months[month]
  68. try:
  69. # then grab the data in the field and process it into the appropriate
  70. # fields of the new table in the correct units
  71. irow.cn_qnty_mo_va = row.getValue(field.name)*1000000
  72. irow.cn_qnty_mo_va_mega = row.getValue(field.name)
  73. except:
  74. #--skip null values
  75. pass
  76. elif field.name not in ignore:
  77. #--if the field name is not a month abbreviation, just copy the data
  78. # to the new table
  79. irow.setValue(field.name,row.getValue(field.name))
  80. irows.insertRow(irow)
  81. del irow,irows
  82. del row,rows
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement