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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:35:09+00:00 2026-05-26T12:35:09+00:00

I have an excel spreadsheet that has 2 columns. Something like this |ColA |

  • 0

I have an excel spreadsheet that has 2 columns. Something like this

|ColA | ColB |
|Key | Value |
|1 | test |
|2 | test2 |
|3 | test4 |

and I want to read these two columns into a dictionary. I currently have this working but can’t figure out how to extract out each key value pair

  sh = wb.sheet_by_index(0)
  for rownum in range(sh.nrows):
      print sh.row_values(rownum)
  • 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-26T12:35:09+00:00Added an answer on May 26, 2026 at 12:35 pm

    You’re very close. If you want to build a dictionary from the a sheet that only contains keys and values, in the first two columns, you can simply do

    print dict(sh.row_values(rownum) for rownum in range(sh.nrows))
    

    As John Y mentioned, if you need to extract two specific columns with indexes i (keys) and j (values), you can do instead:

    print dict((sh.cell_value(rownum, i), sh.cell_value(rownum, j)) for rownum in range(sh.nrows))
    

    The key point is that dict() can build a dictionary from an iterable of (key, value) tuples.

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

Sidebar

Related Questions

We have an existing Traceability Matrix in Excel that has columns like: Project Business
I have an excel spreadsheet that has about 18k rows and three columns. I
I have an Excel spreadsheet that looks like: spreadsheet http://img186.imageshack.us/img186/6495/exelf.jpg I'd like to convert
I have an excel spreadsheet that is password-protected. I need to open this spreadsheet
Ok, so I have an excel spreadsheet that contains data that I would like
I have an Excel Spreadsheet like this id | data for id | more
I have an excel spreadsheet that has dates in the first column, the rest
I have data in an Excel spreadsheet that has 10,000 rows with the following
I have a large Excel spreadsheet with a column that has an identifying number.
I have some data structured like this in an Excel spreadsheet: A B C

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.