VPython: File Read Error
<p>I'm using VIDLE and VPython.  All I'm trying to do is read the values from "weather.txt."  The values that I need to read start on the second line of the file, so I need to skip the first line.  Here's a snippet of my code:</p>

<pre><code>try:
    filename = "âªâªâªC:\Users\Ashley\Documents\weather.txt"
except (ValueError, IndexError), e:
    print e
    sys.exit()

datafile = open(filename, 'r')
datafile.readline()

for line in datafile:
    data = line.split()

    try:
        date = data[2]
        temperature = float(data[3])

        year = float(date[0:4])
        month = float(date[4:6])
        day = float(date[6:8])

        decimalYear = getDecimalYear(year, month, day)

        meanTimes.append(decimalYear)
        meanTemperatures.append(temperature)

    except:
        print "Tossing line", line

datafile.close()
</code></pre>

<p>And, I keep receiving the following error:</p>

<blockquote>
  <p>Traceback (most recent call last):   File "Untitled", line 45
      datafile = open(filename, 'r') IOError: [Errno 22] invalid mode ('r') or filename:
  '\xe2\x80\xaa\xe2\x80\xaa\xe2\x80\xaaC:\Users\Ashley\Documents\weather.txt'</p>
</blockquote>

<p>Any ideas of what exactly I'm doing wrong?  Thanks.</p>

<p>Looks like you need to escape backslashes in the file path. It would also appear that there are invisible unicode characters at the start of your string.</p>

<p>Try using:
<code>filename = 'C:\\Users\\Ashley\\Documents\\weather.txt'</code></p>

<p>Also, the first <code>try: except:</code> block isn't required, there's no way that those exceptions can be raised simply by setting a variable.</p>

python