1

I would like to create tool that will be generate *.csv with information about feature class (field_name, type). You can find my code:

import arcpy import os arcpy.env.overwriteOutput = True dataset_name = arcpy.GetParameterAsText(0) Report_folder = arcpy.GetParameterAsText(1) fields = arcpy.ListFields() for field in fields: print("{0} is a type of {1} with a length of {2}" .format(field.name, field.type, field.length)) 

enter image description here

Could you advise?

3
  • 1
    Apart from ListFields missing the dataset parameter, what is your question? Commented Jan 26, 2021 at 9:44
  • Hi, thanks for your time. I now that I can put path for dataset, but I would like put here dataset_name as in script parameters. fields = arcpy.ListFields('dataset_name') - is it right, if I will put like this? Commented Jan 26, 2021 at 10:17
  • Yes, but without the quotes: fields = arcpy.ListFields(dataset_name) Commented Jan 26, 2021 at 10:45

1 Answer 1

0

This script solved my task:

import arcpy import os import xlwt arcpy.env.overwriteOutput = True Dataset_name = arcpy.GetParameterAsText(0) Report_folder = arcpy.GetParameterAsText(1) fields = arcpy.ListFields(Dataset_name) wb = xlwt.Workbook() ws = wb.add_sheet('Test') ws.write(0, 0, "Field") ws.write(0, 1, "Type") row = 1 for field in fields: print field.name, field.length, field.type ws.write(row, 0, field.name) ws.write(row, 1, field.type) row += 1 
0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.