PYTHON: How to take a .txt file as input from user using raw_input in Python and then read that file row wise?
<p>I want to take a .txt file as input from user through <code>raw_input</code>.</p>

<p>Once the input is taken, I want the txt file name given by user to be accessed and the contents from it written into another file (each in next row).</p>

<p>I am having a problem with how to connect a and b above or how to link raw input with reading of file. I need help...the code is as follows (but it is erroneous :S).</p>

<pre><code>import sys,os,csv

x = raw_input("Enter name of file to be written row wise:")
ui = "x" + txt
for ui in x:
    data = open("ui").readlines()
    outfile = open("myfile.csv","w")
    out = csv.writer(outfile)
for row in data:
    row = row.strip().split(';')
    if row:
        for subrow in row:
            subrow = subrow.strip().split()
            if subrow:
                out.writerow(subrow)
outfile.close()
</code></pre>

<p>I get the error:</p>

<blockquote>
  <p>cannot concatenate 'str' and 'list' objects</p>
</blockquote>
