<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic IOError, file not open for reading in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/ioerror-file-not-open-for-reading/m-p/529746#M41491</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi, &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;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.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Anyone with some ideas where this script goes wrong? Thanks in advance,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
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:
&amp;nbsp; # Same unique key as with the other way, just shorter to type.
&amp;nbsp; key = (line[1:12], line[46:54], line[55:63])
&amp;nbsp; 
&amp;nbsp; # Check if we had this key already. If not write line.
&amp;nbsp; if key not in all_keys:
&amp;nbsp;&amp;nbsp; in_file.write(line)
&amp;nbsp;&amp;nbsp; 
&amp;nbsp; # Now record the key
&amp;nbsp; all_keys.add(key)
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 15 May 2012 12:26:01 GMT</pubDate>
    <dc:creator>Nils_AageHafsal1</dc:creator>
    <dc:date>2012-05-15T12:26:01Z</dc:date>
    <item>
      <title>IOError, file not open for reading</title>
      <link>https://community.esri.com/t5/python-questions/ioerror-file-not-open-for-reading/m-p/529746#M41491</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi, &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;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.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Anyone with some ideas where this script goes wrong? Thanks in advance,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
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:
&amp;nbsp; # Same unique key as with the other way, just shorter to type.
&amp;nbsp; key = (line[1:12], line[46:54], line[55:63])
&amp;nbsp; 
&amp;nbsp; # Check if we had this key already. If not write line.
&amp;nbsp; if key not in all_keys:
&amp;nbsp;&amp;nbsp; in_file.write(line)
&amp;nbsp;&amp;nbsp; 
&amp;nbsp; # Now record the key
&amp;nbsp; all_keys.add(key)
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 May 2012 12:26:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/ioerror-file-not-open-for-reading/m-p/529746#M41491</guid>
      <dc:creator>Nils_AageHafsal1</dc:creator>
      <dc:date>2012-05-15T12:26:01Z</dc:date>
    </item>
  </channel>
</rss>

