Created
May 30, 2017 21:37
-
-
Save tyler-austin/679f08f8afedce7da7a649c208eeb1ab to your computer and use it in GitHub Desktop.
arcpy print first x rows
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import arcpy | |
import os | |
def _print_top_rows(vector_data, num_rows=10): | |
field_names = [f.name for f in arcpy.ListFields(vector_data)] | |
print field_names | |
i_row = 0 | |
with arcpy.da.SearchCursor(vector_data, ['*']) as cursor: | |
for row in cursor: | |
if i_row < num_rows: | |
print row | |
i_row += 1 | |
del cursor | |
vector_data = os.path.join(r"/path/to/feature/class") | |
first_10_rows = _print_top_rows(vector_data) | |
num_rows = 15 | |
first_15_rows = _print_top_rows(vector_data, num_rows) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment