random - pulling an excel sheet with =rand(between) in a Python while loop, and exporting results as .dbf -


to preface question: new stack overflow, , relatively new python.

i working on setting sensitivity analysis. working 40 parameters range 0.1 - 1. analysis requires simultaneously varying these parameters +-0.1 ~500 times. these values fed arcgis tool. so, need 500 sets of random values, 40 parameters. these parameter values compared output of tool, see parameters model sensitive to. i've set excel sheet randomly calculate these values each time it's opened, issue need in .dbf format read arcgis tool.

i have set while loop (for 10 iterations start, need ~500) , tried 2 different methods, in hopes automate process of calling .xls generate random numbers, , exporting .dbf.

the first, arcpy.copyrows_management correctly exported .dbf. issue output exact same each iteration, , instead of having values of 0.1, 0.2, 0.3 etc, contained values of 0.22, 0.37, 0.68 etc. wasn't tenths, though specified in formulas in .xls.

i tried arcpy.tabletotable_conversion throwing error 999999: error executing function.

i open kinds of suggestions. perhaps there easier way randomly sample , export results .dbf in python. not need done using arcpy, i've worked with. appreciate provided! time.

i = 0 while < 10:     # set run specific variables     lulc = "d:\\saruns\\lulc_nosoils_rand.xls\\lulc_nosoils$"     folder = "d:\\saruns"      print "reading lulc"      newlulc = "d:\\saruns\\lulc_nosoils_rand"+str(i)+".dbf"      print "reading newlulc"      # copy rows copying dbf, values inside      # same each run. and, none correct.         arcpy.copyrows_management(lulc, newlulc)      # table table should work. isn't.         # arcpy.tabletotable_conversion(lulc, folder, newlulc)      print "converting table"         i+= 1 

when calculating values in excel decimals. if specify numer format 1 decimal, whole number still there. assume why not "exact numbers" 1 decimal. apply round function 1 decimal only.

copy rows copy values out of dbf, not open excel call formula calculating new random value.

so either have calculate random values in python , create dbase output or need open excel instance - wich shoult trigger new random values - , save excel sheet dbase.

maybe populating arcmap table values using calculatefield_management , exporting data dbase work, i.e. this:

     arcpy.tabletodbase_conversion(tablename, outpath) 

Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

.htaccess - Matching full URL in RewriteCond -