Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3936954
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T00:00:40+00:00 2026-05-20T00:00:40+00:00

Still teaching myself python so please don’t hate me if my code is terrible…

  • 0

Still teaching myself python so please don’t hate me if my code is terrible…

My code:

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

for row in ifile:
    #do some web 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)

Problem: I start with a CSV that I will have to add 3 columns to the end. Using my code above, I get the following output:

HEADER1     HEADER2    HEADER3   result1   result2   result3
autocheck   C:\check   1.jpg     result1   result2   result3
services    C:\svcs    2.jpg     result1   result2   result3

My DESIRED output:

HEADER1     HEADER2    HEADER3   HEADER4   HEADER5   HEADER6
autocheck   C:\check   1.jpg     result1   result2   result3
services    C:\svcs    2.jpg     result1   result2   result3

What is the best way to fix my code that will give me the desired output? My initial thought would be to delete the HEADERS row and replace it with a new HEADERS row in the TE-RESULTS.csv file.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T00:00:41+00:00Added an answer on May 20, 2026 at 12:00 am

    Process the header row before the for loop.

    rowAdd = tempfile.next()
    ofile.writerow(rowAdd + ['HEADER4', 'HEADER5', 'HEADER6'])
    
    for ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im still teaching myself Java so I wanted to try to read a text
I'm teaching myself XSLT and am still trying to wrap my brain around the
I've been teaching myself Python at my new job, and really enjoying the language.
I'm currently teaching myself Python and was just wondering (In reference to my example
Still 'diving in' to Python, and want to make sure I'm not overlooking something.
I still have a problem with the splash screen. I don't want to use
I'm teaching myself cocoa and enjoying the experience most of the time. I have
I am teaching myself PowerShell by writing a simple parser. I use the .Net
When I was first started teaching myself programming, after finishing a tutorial I would
I am teaching myself Android using Eclipse, the Android plug-in, and Sams Teach Yourself

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.