I have a script that I use to convert text files into LAS files- there are 400 files. How would I make a batch script or loop to tell Python to keep grabbing the next file and keep converting until it reaches the end of the folder?
You can loop through a folder to get all your text files.
import os folder= r'path_to_your_folder_of_text_files' for root, dirs, files in os.walk(folder): for filename in files: input_file = os.path.join(root, filename) # You can then run your conversion script here # Use input_file for your input into your script.
Or, since this isn't ESRI data specific, you can use regular old os.walk.
Hi Jackie,
You could try something like the following:
import os for filename in os.listdir('dirname'): if os.path.isfile(filename): # code to convert file here
<SPAN class="kwd" style="color: #00008b;"></SPAN>
I would look into using arcpy.da.walk.
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.