IOError, file not open for reading

1001
0
05-15-2012 05:26 AM
Nils_AageHafsal1
New Contributor
Hi,

I have a nifty script for deduplicating coordinates (not made it myself, a redditor helped me). However, I would like to get it to work with an arcpy toolbox. I get this IOError, saying the script can't write to the file.

Anyone with some ideas where this script goes wrong? Thanks in advance,

import arcpy
in_name = arcpy.GetParameterAsText(0)
with open(in_name, 'w') as in_file:
 # Records unique keys as we find them
 all_keys = set()
 
 for line in in_file:
  # Same unique key as with the other way, just shorter to type.
  key = (line[1:12], line[46:54], line[55:63])
  
  # Check if we had this key already. If not write line.
  if key not in all_keys:
   in_file.write(line)
   
  # Now record the key
  all_keys.add(key)
Tags (2)
0 Kudos
0 Replies