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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:57:57+00:00 2026-05-25T15:57:57+00:00

I have Python script which retrieves data from an API in JSON format (at

  • 0

I have Python script which retrieves data from an API in JSON format (at least I think its JSON format). I want to loop through each ‘object’ and write to a CSV file.

Here is the data returned from the api:

[
{
    "bids_won": "7",
    "partner_revenue": "$0.01",
    "profit": "$0.00",
    "campaign_id": "test 1", 
    "post_click_conversions": "0", 
    "total_cost": "$0.01",
    "total_media_cost": "$0.01",
    "post_view_conversions": "2", 
    "adjusted_partner_cost": "$0.01", 
    "clicks": "0",
    "day": "August 21, 2011"
},
{
    "bids_won": "30,209", 
    "partner_revenue": "$38.67", 
    "profit": "$8.92", 
    "campaign_id": "test 2", 
    "post_click_conversions": "0", 
    "total_cost": "$29.75", 
    "total_media_cost": "$29.75", 
    "post_view_conversions": "0", 
    "adjusted_partner_cost  ": "$25.26", 
    "clicks": "10", 
    "day": "August 21, 2011"
}
 ]

How can I loop through these ‘objects’ and write them to a CSV file? My current attempt to loop through it results in the script interating through each letter..

Appreciate the help.

ps I’m using python 2.7

  • 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-25T15:57:58+00:00Added an answer on May 25, 2026 at 3:57 pm

    In the end I was given a slightly different URL for the request which returned raw CSV. I dumped the content into a CSV file:

    f = open('report.csv', 'wb')
    f.write(response_content)
    f.close
    

    Its not an ideal solution because I still cannot loop through the CSV objects (goes through each character) but I’m able to create a resonably well formatted csv file so its ok for now.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a python script which outputs lots of data, sample is as below.
I have a Python script which uses a glade file to define its UI,
I have a Python CGI script from which I am trying to call a
I have a python script which is constantly polling data. The script is constantly
So I have a python script that runs a loop in which it calls
I have got a python script which is creating an ODBC connection. The ODBC
I have a PHP script which executes a shell command: $handle = popen('python last',
I have an external C# program which executes a Python script using the Process
I have a python script which is querying a MySQL server on a shared
I have a python script which process a file line by line, if the

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.