inFile = open (arcpy.GetParameterAsText(0),'r') outFile = open (arcpy.GetParameterAsText(1),'w') buffer = [] for line in inFile:: line = line.strip() buffer = line.split(' ') buffer = filter (None, buffer) outFile.writelines(",".join(buffer)) outFile.writelines("".join('\n')) inFile.close() outFile.close()
Solved! Go to Solution.
I'm happy to try and help you, but I'll need a bit more info from you first. Please post the input file or at least a few sample lines of what the file contents look like.
I first wrote a simple script to format the data as comma delimited.
Just curious, is the file you provided the modified one from the script or is it the original? Please provide the original if possible.
Which version of ArcGIS are you working with?
I am not sure of your computer settings, but if you would like me to help with the code please provide an example of the original source file. You said that you were altering the TXT files to become comma-delimited, so whatever you are running the script against is what I would need to start with. It sounds like the script you wrote isn't quite right as it is truncating certain values or you are getting NULL returns on others. It's possible that we could write some alternate Python that would convert your source file(s) directly to Shapefile format without having to produce an intermediate comma-separated file. Without that, I can't troubleshoot your output file.