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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T20:13:03+00:00 2026-06-16T20:13:03+00:00

I have a large csv file with approximately 170 columns’ worth of numerical data

  • 0

I have a large csv file with approximately 170 columns’ worth of numerical data (the columns) for about 1000 individuals (the rows). What I’d like to do is pipe a particular value for a particular case from the csv file into a text file.

More specifically, my csv file begins with a column of ID numbers (cases), and about 170 columns containing various numerical datapoints for each case. I want to iterate through the csv file and pull column 17 (as an example) for “CASE156” (as an example), and save the data at that location as:

CASE156_column_17.txt

To initially read in the data, I am using the Python csv builtin as:

f =csv.reader(open('genotypes.csv','rbU'))

I have tried

rownum=0
for row in f:
     if rownum=='CASE156':
         print column[16]

However, this does not produce the desired result. How can I can pull a specific column’s data for a specific case?

To make matters slightly more complicated, if there is NO data at that cell, I would like to skip it and NOT produce a .txt file.

Many thanks in advance,

  • 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-16T20:13:04+00:00Added an answer on June 16, 2026 at 8:13 pm

    Let’s assume that the key you are looking for is located in column ‘key_index’
    then you can use:

    f = csv.reader(open('genotypes.csv','rbU'))
    key_index = 22  # assuming that this column contains something like 'CASE156'
    for rownum, row in enumerate(f):
        if row[key_index] == 'CASE156':
             print row[16]
    

    Reading basic Python documentation appreciated.

    You can also use DictReader making the CSV data a bit more approachable through a dict
    instead of a row that you can only access by column number.

    http://docs.python.org/2/library/csv.html#csv.DictWriter

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

Sidebar

Related Questions

I have a very large csv file (about 91 million rows so a for
I have a large CSV data file -- ~1,444,000 rows of data -- that
I have a large 2 column csv file (data.csv) with a weeks worth of
I have a large CSV file (5.4GB) of data. It's a table with 6
I have some large csv file, with about 200 header names (the first one
I have a large CSV file with many columns, something like this: id, col1,
I have a large data coming from a csv file which looks something like
I have a large file, with 1.8 million rows of data, that I need
Requirements I have a very large CSV file to read. (about 3 GB) I
I have a CSV file with 550,000+ rows. I need to import this data

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.