I'm not sure exactly, but try running this. Is it duplicating your entire list each time?import os
import arcpy
workspace = r"C:\working\roger"
output = r"C:\testlist.txt"
def inventory_data(workspace, datatypes, output):
"""
Generates full path names under a catalog tree for all requested
datatype(s).
Parameters:
workspace: string
The top-level workspace that will be used.
datatypes: string | list | tuple
Keyword(s) representing the desired datatypes. A single
datatype can be expressed as a string, otherwise use
a list or tuple. See arcpy.da.Walk documentation
for a full list.
"""
with open(output, "w") as outFile:
for path, path_names, data_names in arcpy.da.Walk(
workspace, datatype=datatypes):
for data_name in data_names:
outFile.write(os.path.join(path, data_name) + os.linesep)
inventory_data(workspace, "Any", output)
Edit: I think I see the issue, you have too many loops here. Try my revised code above.Edit2: Silly me the issue is just the lijn variable keeps building up with each loop. Just remove that entirely.import os
import arcpy
workspace = r"T:\test"
output = r"H:\testlist.txt"
def inventory_data(workspace, datatypes):
"""
Generates full path names under a catalog tree for all requested
datatype(s).
Parameters:
workspace: string
The top-level workspace that will be used.
datatypes: string | list | tuple
Keyword(s) representing the desired datatypes. A single
datatype can be expressed as a string, otherwise use
a list or tuple. See arcpy.da.Walk documentation
for a full list.
"""
for path, path_names, data_names in arcpy.da.Walk(
workspace, datatype=datatypes):
for data_name in data_names:
yield os.path.join(path, data_name)
with open(output, "w") as outFile:
for f in inventory_data(workspace, "Any"):
outFile.write(f + os.linesep)