title: TypeError: coercing to Unicode: need string or buffer, list found
body: <p>I'm trying to get a data parsing script up and running. It works as far as the data manipulation is concerned. What I'm trying to do is set this up so I can enter multiple user defined CSV's with a single command. </p>
  
  <p>e.g.</p>
  
  <pre><code>&gt; python script.py One.csv Two.csv Three.csv 
  </code></pre>
  
  <p>If you have any advice on how to automate the naming of the output CSV so that if <code>input = test.csv</code>, <code>output = test1.csv</code>, I'd appreciate that as well.</p>
  
  <p>Getting</p>
  
  <pre><code>TypeError: coercing to Unicode: need string or buffer, list found
  </code></pre>
  
  <p>for the line</p>
  
  <pre><code>for line in csv.reader(open(args.infile)):
  </code></pre>
  
  <p>My code:</p>
  
  <pre><code>import csv
  import pprint
  pp = pprint.PrettyPrinter(indent=4)
  res = []
  
  import argparse
  parser = argparse.ArgumentParser()
  
  #parser.add_argument("infile", nargs="*", type=str)
  #args = parser.parse_args()
  
  parser.add_argument ("infile", metavar="CSV", nargs="+", type=str, help="data file") 
  args = parser.parse_args()
  
  
  with open("out.csv","wb") as f:
      output = csv.writer(f) 
      for line in csv.reader(open(args.infile)): 
          for item in line[2:]:
  
              #to skip empty cells
              if not item.strip():
                  continue
  
              item = item.split(":")
              item[1] = item[1].rstrip("%")
  
              print([line[1]+item[0],item[1]])
              res.append([line[1]+item[0],item[1]])
              output.writerow([line[1]+item[0],item[1].rstrip("%")])
  </code></pre>
  
  <p>I don't really understand what is going on with the error. Can someone explain this in layman's terms?</p>
  
  <p>Bear in mind I am new to programming/python as a whole and am basically learning alone, so if possible could you explain what is going wrong/how to fix it so I can note it for future reference. </p>