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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:17:29+00:00 2026-06-13T23:17:29+00:00

I am stuck on a problem where my script writes to multiple columns and

  • 0

I am stuck on a problem where my script writes to multiple columns and not rows. I’m not sure what I am doing wrong.

Disclosure – I am really new to programming.

EDIT – Figured it out. This worked 🙂

Any thoughts?

import json
import csv
import subprocess
import urllib
import requests
from unidecode import unidecode

def main():
    list_writer= open_csv()
    info = test_method()
    for list in info:
        write_to_csv(list_writer, list)


def test_method():
    r = requests.get('https://api.github.com/legacy/repos/search/python'+'?start_page=1', auth=('user', 'pass'))
    dict_of_repos = json.loads(r.text)
    list_of_repos = dict_of_repos["repositories"]
    repo_information = []
    for repo in list_of_repos:
        indiv_repo = []
        indiv_repo.append(repo["name"])
        indiv_repo.append(repo["fork"])
        print indiv_repo
        repo_information.append(indiv_repo)
    return repo_information

def open_csv():
    github_csv = open('Githubcsv_1_2.csv', 'wb')
    writer = csv.writer(github_csv)
    return writer   

def write_to_csv(list_writer, info):
    list_writer.writerow(info)
    return

if __name__ == '__main__':
    main()
  • 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-13T23:17:30+00:00Added an answer on June 13, 2026 at 11:17 pm

    it looks like your repo_information will look like

    [
      ['name'],
      ['name2'],
      ['name3']
    ]
    

    so it looks like all you need is to writerows

    def write_to_csv(list_writer, info):
        list_writer.writerows(info)
    

    This, of course, will write all the data to one column (each name being on a seperate row). If you want to write it all to the same row you could:

    for repo in list_of_repos:            
            repo_information.append(repo['name'])
        print repo_information # ['name', 'name2', 'name3']
        return repo_information
    

    and then writerow like you are currently doing. This would then put all the names in the same row.

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

Sidebar

Related Questions

I'm stuck on a problem I really don't know how to solve: I have
I'm quite stuck with a problem sending mail from a PHP script. Some data:
I'm been stuck on this problem for a while and I'm pretty sure it
I have a Perl script which reads three files and writes new files after
I'm trying to write my own lightbox script but I'm stuck on a problem.
I stuck with problem of mail application , i am developing a website for
im stuck with a problem im basically trying to create a function where I
I'm stuck with a problem and ask for your help. It's about navigation within
I am stuck with a problem when testing my controllers with RSpec - the
I got stuck in this problem for an hour. I am thinking this is

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.