def testtlist_to_table(self): ot = arcpy.CreateScratchName('tmp.dbf', workspace='c:\\temp') colnames = ['NAME', 'POP_EST'] coltypes = ['TEXT', 'DOUBLE'] collengths = [250, '#'] coldefs = zip(colnames, coltypes, collengths) # read data tl = [] with arcpy.da.SearchCursor(self.t_fc, colnames) as sc: for row in sc: tl.append(tuple(row)) # write as table ot = ap.tlist_to_table(tl, ot, coldefs, -9, 'nullText') ap.head(ot) est = int(arcpy.GetCount_management(ot).getOutput(0)) obs = int(arcpy.GetCount_management(self.t_fc).getOutput(0)) arcpy.Delete_management(ot) self.assertEqual(est, obs) pass
def testhead(self): est = 5 hd = ap.head(self.t_fc, est, geoms = " ", verbose=False) obs = len(hd[0]) self.assertEqual(est, obs) pass
# We have our data in a text file, which we need to import into ArcGIS native # format. We strongly recommend Esri File Geodatabase. # ap has short name tviw for arcpy.management.CreateTableView, # flyr and rlyr for CreateFeatureLayer and CreateRasterLayer. tb = ap.tviw(text, "tb") # check that the names and data types are what you would expect ap.names(tb) ap.types(tb) # or like this: zip(ap.names(tb), ap.types(tb)) # It is point data so let's convert it to a point feature class. # Store it as a point feature class called 'dta' in our base.gdb. fc = ap.to_points(tb, ap.to_scratch('dta'), 'x', 'y', 28992) tmp = ap.head(fc) # We don't need the table view of text any more so get rid of it. ap.dlt(tb) # And we don't need the text file itself either so get rid of it. ap.dlt(text) # Print first 10 records using default settings (columns as rows) tmp = ap.head(fc) # now print 5 rows as a formatted table, print '-' for geometries tmp = ap.head(fc, 5, False, '|', '-') # Print some basic statistics for each column. tmp = ap.summary(fc) # Force lime, soil, and ffreq to be treated as categorical variables. tmp = ap.summary(fc, ['lime', 'soil', 'ffreq'], ['CAT', 'CAT', 'CAT'])
# We have our data in a text file, which we need to import # into ArcGIS native format, ideally Esri File Geodatabase. # ap has short name tviw for arcpy.management.CreateTableView, # flyr and rlyr for CreateFeatureLayer and CreateRasterLayer. tb = ap.tviw(text, "tb") # check that the names and data types are what you would expect ap.names(tb) ap.types(tb) # or maybe: zip(ap.names(tb), ap.types(tb)) # It is point data so let's convert it to a point feature class. # Store it as a point feature class called 'dta' in our base.gdb. fc = ap.to_points(tb, ap.to_scratch('dta'), 'x', 'y', 28992) tmp = ap.head(fc) # We don't need the table view of text any more so get rid of it. ap.dlt(tb) # And we don't need the text file itself either so get rid of it. ap.dlt(text) # Print first 10 records using default settings (columns as rows) tmp = ap.head(fc) # now print 5 rows as a formatted table, print '-' for geometries tmp = ap.head(fc, 5, False, '|', '-') # Print some basic statistics for each column. tmp = ap.summary(fc) # Force lime, soil, and ffreq to be treated as categorical variables. tmp = ap.summary(fc, ['lime', 'soil', 'ffreq'], ['CAT', 'CAT', 'CAT']) # Make a quick map