title: How does python access the file from a right click on Windows
body: <p>I've written a simple python script that takes a .csv file, rearranges it and spits out an excel file. My aim is to be able to right click on a .csv file in Windows and for it to generate an .xslx file. I've used PyInstaller to successfully create an .exe and I've used <a href="http://defaultprogramseditor.com/" rel="nofollow noreferrer">default programs editor</a> to put my executable in the context menu when csv files are right clicked. What I can't figure out is how to do the I/O correctly.</p>
  
  <p>What I have is :</p>
  
  <pre><code>import fileinput
  import csv
  try: 
      csv_filename = fileinput.filename()
      print(csv_filename)
  except: print('no input')
  with open(filename_csv, 'rt', newline='', encoding='utf8') as csvfile:
      # do stuff
  # write xslx_filename
  </code></pre>
  
  <p>Which doesn't work. </p>
  
  <p>How do I access the file windows passes me when I open a file?</p>
  
  <p><strong>Edit:</strong>
  Just to clear up confusion. If I hard code the location of a csv file, my script works just fine. My problem is how do I access the file that Windows (presumably) passes to my script when I right click on a csv file and choose to open with csv2xslx (my script).</p>