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 8454563
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:03:40+00:00 2026-06-10T12:03:40+00:00

I have a Tuple result from mysql like this : sqlResult=({‘Count’: 1L, ‘gname’: ‘Anron

  • 0

I have a Tuple result from mysql like this :

sqlResult=({'Count': 1L, 'gname': 'Anron may'}, {'Count': 1L, 'gname': 'Anchy de'}, {'Count': 1L, 'gname': 'abby ras'}, {'Count': 2L, 'gname': 'Akki nome'}, {'Count': 41L, 'gname': 'Archenemy'}, {'Count': 1L, 'gname': 'Antony papa'}, {'Count': 1L, 'gname': 'Dead zombie'})

I am trying to save this data to CSV file like this

import time
csvName="Gnames-and-count-"+str(int(time.time()))
csvPath="/home/sean/Desktop/"+str(csvName)+str(".csv")
writer = csv.writer(open(csvPath, 'wt'))
for results in sqlResult:
    writer.writerow([results['gname'],int(results['Count'])])

The file is created at the following path but nothing is there on the file.
Is there any obvious thing i am missing? .Please guide me.

  • 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-10T12:03:41+00:00Added an answer on June 10, 2026 at 12:03 pm

    You need to close the file. Let with do it for you.

    with open(csvPath, 'w') as f:
        writer = csv.writer(f)
        for results in sqlResult:
            writer.writerow([results['gname'],int(results['Count'])])
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say we have a data structure like this: var sequences = new List<Tuple<int,
I am using MySQL 5.5. I have a query which returns results like this
I have a loop which, once simplified, looks like this: Dictionary<Tuple<A,G>,Decimal> results = new
I have a tuple, like ('key1', 'value1') that I want to add that to
I have a 3-tuple list like the following [I added line breaks for readability]:
how to write a function from list to a tuple i have taken the
I have following var result = new List<Tuple<int, List<ProductionReportEntry>, int>>(); How I can sort
I would like to know how to pass a list/set/tuple from python (via psycopg2)
Say you have a tuple and want to generate a new tuple by applying
How can i have a tuple that has a list as a value. F.x.

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.