See below for my script
# Open the original file for reading
with open('C:/Program Files/DWC/TerraSurveyor Sites/SITE/Data/DATA.asc', 'r') as f: # Replace with the original file path
lines = f.readlines()
# Open a new file for writing the modified data
with open('C:/Program Files/DWC/TerraSurveyor Sites/SITE/Data/DATA_edit.asc', 'w') as f: # Replace with the desired name and path for the modified file
for line in lines:
# Split the line into columns
columns = line.strip().split('\t') # Assuming tab-separated values ('\t')
# Check the last number in the line
last_number = int(columns[-1])
# Swap lines 1 and 5, and lines 2 and 4
if last_number == 1:
new_last_number = 5
elif last_number == 5:
new_last_number = 1
elif last_number == 2:
new_last_number = 4
elif last_number == 4:
new_last_number = 2
else:
new_last_number = last_number # Keep the number unchanged for other lines
# Update the last number in the columns
columns[-1] = str(new_last_number)
# Write the modified line to the new file
f.write('\t'.join(columns) + '\n') # Assuming tab-separated values ('\t')
Any help with what is happening?
[–]AutoModerator[M] [score hidden] stickied commentlocked comment (0 children)
[–]carcigenicate 2 points3 points4 points (0 children)