title: Converting text file to .xlsx in python
body: <pre><code>10 4
  
  0 0 0 0
  
  0 0 1 0
  
  1 0 2 0
  
  2 2 0 1
  
  0 0 1 1
  
  0 1 2 1
  
  1 1 1 1
  
  1 2 2 0
  
  0 0 1 0
  
  2 0 1 0
  </code></pre>
  
  <p>I want to read the above text file store this in xlsx format. But with my code whole row is stored in same cell. But I want them in different cells. Each item is space seperated.</p>
  
  <pre><code>import pandas as pd
  
  df=pd.read_csv('input.txt')
  
  df.to_excel('test2.xls',index=False)
  </code></pre>
  
  <p>Expected result: Each item stored in different cell.</p>
  
  <p>Note that the first row only has 2 elements.</p>