title: Value Error: Invalid Literal for int() with base 10: 'import' - Python
body: <p>When I'm running this code:</p>
  <pre><code>def main():
  
      maze = []
  
      maze_1d_arr = open(sys.argv[0], 'r')
  
      maze_read = maze_1d_arr.readline()
  
      maze_split = maze_read.split(&quot; &quot;)
  
      size_X = int(maze_split[0])
      size_Y = int(maze_split[1])
  
      maze_grid = int(maze_split[2:])
  
      maze = np.array(maze_grid).reshape(size_X, size_Y)
  
      start = np.where(maze_split == 2)
      end = np.where(maze_split == 3)
  
      path = astar(maze, start, end)
      print(path)
  </code></pre>
  <p>I am getting this error;</p>
  <pre><code>    size_X = int(maze_split[0])
  ValueError: invalid literal for int() with base 10: 'import'
  </code></pre>
  <p>Is there any way this can be fixed? It is coming from a text file which has this one line:</p>
  <pre><code>6 4 0 0 1 0 0 0 2 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0 3 0
  </code></pre>
  <p>As a bit of background on the file, the first number is supposed to represent the x axis, the second number is supposed to represent the y axis and the third number onwards is the grid.</p>
  <p>Many thanks :)</p>
  <p>EDIT:
  I have changed the code to this:</p>
  <pre><code>def main():
  
      maze = []
  
      maze_1d_arr = open(sys.argv[1], 'r')
  
      maze_read = maze_1d_arr.readline()
  
      maze_split = maze_read.split(&quot; &quot;)
  
      size_X = [int (X) for X in maze_split[0]]
      size_Y = [int (Y) for Y in maze_split[1]]
  
      maze_grid = [int (x) for x in maze_split[2:]]
  
      maze = np.array(maze_grid).reshape(size_X, size_Y)
  
      start = np.where(maze_split == 2)
      end = np.where(maze_split == 3)
  
      path = astar(maze, start, end)
      print(path)
  </code></pre>
  <p>But I'm now getting this error,</p>
  <pre><code>size_Y = [int (Y) for Y in maze_split[1]]
  IndexError: list index out of range
  </code></pre>
  <p>I am still using the same file as before for the code, any ideas on how to fix this?</p>