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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T20:18:44+00:00 2026-06-08T20:18:44+00:00

I have a .csv with 3000 rows of data in 2 columns like this:

  • 0

I have a .csv with 3000 rows of data in 2 columns like this:

uc007ayl.1  ENSMUSG00000041439
uc009mkn.1  ENSMUSG00000031708
uc009mkn.1  ENSMUSG00000035491

In another folder I have a graphs with name like this:

uc007csg.1_nt_counts.txt
uc007gjg.1_nt_counts.txt

You should notice those graphs have a name in the same format of my 1st column

I am trying to use python to identify those rows that have a graph and print the name of 2nd column in a new .txt file

These are the codes I have

import csv
with open("C:/*my dir*/UCSC to Ensembl.csv", "r") as f:
reader = csv.reader(f, delimiter = ',')
    for row in reader:
        print row[0]

But this as far as I can get and I am stuck.

  • 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-08T20:18:45+00:00Added an answer on June 8, 2026 at 8:18 pm

    You’re almost there:

    import csv
    import os.path
    with open("C:/*my dir*/UCSC to Ensembl.csv", "rb") as f:
        reader = csv.reader(f, delimiter = ',')
        for row in reader:
            graph_filename = os.path.join("C:/folder", row[0] + "_nt_counts.txt")
            if os.path.exists(graph_filename):
                print (row[1])
    

    Note that the repeated calls to os.path.exists may slow down the process, especially if the directory lies on a remote filesystem and does not significantly more files than the number of lines in the CSV file. You may want to use os.listdir instead:

    import csv
    import os
    
    graphs = set(os.listdir("C:/graph folder"))
    with open("C:/*my dir*/UCSC to Ensembl.csv", "rb") as f:
        reader = csv.reader(f, delimiter = ',')
        for row in reader:
            if row[0] + "_nt_counts.txt" in graphs:
                print (row[1])
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have CSV data of a log for 24 hours that looks like this:
I have a CSV file that goes something like this: ['Name1', '', '', '',
I have a csv file that has like 30,000 rows in it. It also
I have csv file with a line that looks something like this: ,,,,,,,,,, That's
I have csv file like this: item,#RGB item1,#ffcc00 item1,#ffcc00 item1,#ff00cc item2,#00ffcc item2,#ffcc00 item2,#ffcc00 item2,#ffcc00
I have a folder with 3000 csv files ranging in size from 1Kb to
I have a CSV file that looks like this, where time is a UNIX
I have a csv file that looks like this: Please note, there are no
I have CSV data loaded into a multidimensional array. In this way each row
I have csv values like this: $csv_data = test,this,thing hi,there,this is,cool,dude have,fun; I want

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.