-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCreateSchemaXLS.py
More file actions
52 lines (40 loc) · 1.42 KB
/
CreateSchemaXLS.py
File metadata and controls
52 lines (40 loc) · 1.42 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
43
44
45
46
47
48
49
50
51
52
import arcpy
import pandas
# Lists for pandas dictionary
fieldName = []
fieldType = []
fieldLength = []
fieldPrecis = []
# For each field in the feature class, print
# the field name, type, length, and precision.
fields = arcpy.ListFields(r"C:\Users\andolson\Documents\WORKING\UST_LUST\Data\MA\BWP_PT_UST.shp")
for field in fields:
# Print field properties
# print("Field: {0}".format(field.name))
# print("Type: {0}".format(field.type))
# print("Length: {0}".format(field.length))
# print("Precision: {0}".format(field.precision))
fieldName.append(field.name)
fieldType.append(field.type)
fieldLength.append(field.length)
fieldPrecis.append(field.precision)
# print(fieldName)
# print(fieldType)
# print(fieldLength)
# print(fieldPrecis)
thisdict = {"Field": fieldName,
"Type": fieldType,
"Length": fieldLength,
"Precision": fieldPrecis
}
# Create a Pandas dataframe from the data.
df = pandas.DataFrame(thisdict)
# Create a Pandas Excel writer using XlsxWriter as the engine.
writer = pandas.ExcelWriter(r'C:\Users\andolson\Documents\WORKING\pandas_simple0.xlsx')
# Convert the dataframe to an XlsxWriter Excel object.
df.to_excel(writer, sheet_name='Sheet1')
# Close the Pandas Excel writer and output the Excel file.
# Output excel file is written in the same location where the
# script is saved.
writer.save()
print(thisdict)