1

I'm writing data to a CSV but the current output is as follows: (the top row is the headers)

 A    VC_s                                       VC_i    VT_s
 1    (['Not Reported'],['reported'],['click'])   
 2    (['Not Reported'],['reported'],['click'])

The desired output is as follows:

 A    VC_s            VC_i         VT_s
 1    Not Reported    reported     click
 2    Not Reported    reported     click

The code I've got so far is:

ifile = csv.reader(open("input.csv",'rb'))
shutil.copy("input.csv","temp")
tempfile = csv.reader(open("temp","rb"))
ofile = csv.writer(open("RESULTS.csv","ab"))

for row in ifile:
    #do some table scraping stuff here
    VC_s = str(cells[1].find(text=True))
    VC_i = str(cells[2].find(text=True))
    VT_s = str(cells[4].find(text=True))

    entry = ([VC_s], [VC_i], [VT_s])
    rowAdd = tempfile.next()
    ofile.writerow(rowAdd + [entry])

What am i doing wrong and how can I fix this? It would seem like an easy fix but I am stumped.

2 Answers 2

1
entry = [VC_s, VC_i, VT_s]
rowAdd = tempfile.next()
ofile.writerow(rowAdd + entry)
Sign up to request clarification or add additional context in comments.

Comments

0

You just want entry = [VC_s, VC_i, VT_s]

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.