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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:46:59+00:00 2026-06-03T05:46:59+00:00

I am using the following code to combine two text files: def combine_acpd_ccs(self, ccs_file,

  • 0

I am using the following code to combine two text files:

def combine_acpd_ccs(self, ccs_file, acps_file, out_file):

    with open(ccs_file, 'r') as in_file1:
        with open(acps_file, 'r') as in_file2:
            with open(out_file, 'w') as out1:
                out1.write('PDB\tPA\tEHSS\tACPS\n')
                for line in in_file1:
                    segs = line.split()
                    for i in in_file2:
                        sse_score = i.split()
                        #print line
                        #print segs
                        if segs[0][:-4] == sse_score[0]:
                            out1.write(segs[0][:-4]+'\t'+segs[1]+'\t'+segs[2]+'\t'+sse_score[1]+'\n')

Example data looks like:

ccs_file:

1b0o.pdb    1399.0  1772.0
1b8e.pdb    1397.0  1764.0

acps_file:

1b0o    0.000756946316066
1b8e    8.40662008775
1b0o    6.25931529116

I expected my out put to be like:

PDB PA  EHSS    ACPS
1b0o    1399.0  1772.0  0.000756946316066
1b0o    1399.0  1772.0  6.25931529116
1b8e    1397.0  1764.0 8.40662008775

But my codes just generates the top two lines of my expected output. If I print segs in the second for loop only the first line in ccs_file is passed to the loop. Any ideas where I have gone wrong?

  • 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-03T05:47:00+00:00Added an answer on June 3, 2026 at 5:47 am

    The problem is that you don’t reopen/rewind in_file2 after each iteration of the outer loop.

    Having executed

    for i in in_file2:
    

    all subsequent attempts to iterate over in_file2 will do nothing, since the file pointer is already positioned at the end of the file.

    If the files are relatively small, you might want to load ccs_file into memory, and just do dictionary lookups.

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

Sidebar

Related Questions

Using following code I try to get updated list of checkbuttons' corresponding text values,
I am using following code to combine .mp4 and .caf into .mov . (Note
I am using the following code to read and combine number of texts in
I using following code: var search = 'test'; if ($('#sku').find(search) ){ //alert(search); $(document).find(search).css('color','red'); <TABLE>
I am using following code to handle all the unhandled exceptions in the program.
I am using following code to remove some specific nodes from xml file..It show
I am using following code in rowdatabound function. Protected Sub gvwMileStone_RowDataBound(ByVal sender As System.Object,
I am using following code to check whether a check box on my website
I am using following code to design my home page. The output (as shown
I'm using following code but cannot return data from MySQL. This is the output:

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.