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

  • SEARCH
  • Home
  • 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 7830895
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T11:27:18+00:00 2026-06-02T11:27:18+00:00

I am trying to write the below information to a csv file in this

  • 0

I am trying to write the below information to a csv file in this format:

Tmin, -40

However my output looks like the below with the brackets and quotes around the -40:

Tmin, [‘-40’]

My code is below. Basically I am searching through a csv file for a specific phrase, in this case “Tmin”, and reading the entry 1 cell to the right. I then want to write both “Tmin” and the value read directly to a second csv file.

I have searched for a way to remove the quotes and brackets but have not been able to get it to work. I am pretty new to python so any help would be helpful. Thanks.

import csv
fileInput = "Input.csv"
fileOutput = "output.csv"
Name_Column = 0
Value_Column = 1

with open(fileInput, 'r') as file:
    reader = csv.reader(file)
    Tmin = [line[Value_Column] for line in reader if line[Name_Column] == 'Tmin']
    print "Tmin=", Tmin    #print to screen to check value read

with open (fileOutput,'w') as file:
   writer = csv.writer(file)
   print writer.writerow(['Tmin',Tmin])
  • 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-06-02T11:27:22+00:00Added an answer on June 2, 2026 at 11:27 am

    python is just printing the Tmin as a list, you can either print the CSV row as a string, or just the first element in the row.

    Try

    print "Tmin=", ", ".join(Tmin)
    

    or

    print "Tmin=", Tmin[0]
    

    if you want to have csv output through the csv writer, you need a single list, not a list inside a list:

    Try

    writer.writerow(['Tmin']+Tmin) #note this is already printing the result to a file so dont "print" the return value
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a C program like the one below. I am trying to write
I'm trying to load a existing pdf file, and fill this with database information.
I’m trying to write a response from a Solr server to a CSV file.
I'm trying to write a file using VBA. My code is below. It worked
This is my app.config file looks like: <?xml version=1.0 encoding=utf-8 ?> <configuration> <appSettings> <add
I'm trying to write sql that produces the desired result from the data below.
(In short: main()'s WaitForSingleObject hangs in the program below). I'm trying to write a
Trying to write a RE to recognize date format mm/dd in Python reg =
Trying to write a couple of functions that will encrypt or decrypt a file
Trying to write a chat, like on facebook, I wondered if two clients can

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.