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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T16:26:40+00:00 2026-06-18T16:26:40+00:00

I am looking for a pythonic and concise way to select a column in

  • 0

I am looking for a pythonic and concise way to select a column in a .csv file and store all cells of the column in, e.g., a list.

import csv    

with open("/path/to/file.csv","r") as csvfile:
    reader = csv.DictReader(csvfile, delimiter=";")
    # TODO: select column for key "foo"
    # TODO: select column for key "bar"
    # TODO:store "foo" data in list
    # TODO: store "bar" data in list
  • 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-18T16:26:41+00:00Added an answer on June 18, 2026 at 4:26 pm

    It’s straightforward to get columns out of DictReader row dicts in pure Python, and someone else is probably writing an answer to that effect right now, so instead of duplicating that effort I’ll show how to do this in one of my favourite Python libraries for data manipulation, pandas:

    >>> import pandas as pd
    >>> df = pd.read_csv("somefile.csv", sep=";")
    >>> df
       foo  bar      apple
    0    1  100       pear
    1    2  200     orange
    2    3  300  tangerine
    3    4  400      peach
    >>> df["foo"]
    0    1
    1    2
    2    3
    3    4
    Name: foo
    >>> df["bar"]
    0    100
    1    200
    2    300
    3    400
    Name: bar
    >>> df["foo"] * df["bar"]
    0     100
    1     400
    2     900
    3    1600
    >>> list(df["foo"] * df["bar"])
    [100, 400, 900, 1600]
    

    In the dark pre-pandas days I had my own hand-crafted library for this kind of data access. After about fifteen minutes with pandas a few years ago I tossed it..

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

Sidebar

Related Questions

I'm looking for a fast, clean, pythonic way to divide a list into exactly
I am looking for the most pythonic way of splitting a list of numbers
I'm looking for a Pythonic way to get all the diagonals of a (square)
I'm looking for a clean, Pythonic, way to eliminate from the following list: li
I'm looking for the most pythonic way to implement a version of the list
I'm looking for nice pythonic way of filtering one list by another stop-list, but
I'm looking for a pythonic way of iterating over first n items of an
I am looking for pythonic way to split a sentence into words, and also
I am looking for the most pythonic way to replace the first and last
I am looking for a Pythonic way (the less code possible) to unite 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.