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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T04:24:08+00:00 2026-06-07T04:24:08+00:00

This is my current code. I want to check the two values(lines) to check

  • 0

This is my current code. I want to check the two values(lines) to check for matches in the files.

def checkOS():
    fid1 = open("C:/Python/NSRLOS.txt", 'r')
    fid2 = open("C:/Python/sha_sub_hashes.out", 'r')
    outdata = open("osMatches.txt", 'w')
    line1 = fid1.readline()
    line2 = fid2.readline()
    while(line1 and line2):
        xline= line1.split(',')[1]
        yline = line2.split("|")[3]
        zline = xline.replace('"','')
        if (yline == zline):
            outdata.append([yline , zline])
            print xline, zline

if __name__=="__main__":
    checkOS()

The only problem is I’m not sure what I’ve written does that, all the code before the if statement is just reformatting to be able to pull from the index of the line. What I want to know is if the statement I used works in that sense and is it efficient? Then I want to output the equal values.
Here are some lines in the files:

file2:
"10","Amstrad 6128","Unknown","1006"
"100","Macintosh 9.0","8.5.1","67"
"101","Macintosh 9.0.4","na","67"
"102","Macintosh 9.1","9.1","67"
"103","Macintosh 9.2","9.2","67"
"104","Macintosh 9.2.2","9.2.2","67"
"105","Macintosh 9.x","9.X","67"
"106","Macintosh X","10","67"
"107","Macintosh7.5.3","7.5.3","67"
"108","NetWare","n/a","674"
"109","Novel Dos 7.0","7","609"
"11","Apple II+","Unknown","67"
"110","OS/2","Unknown","427"



file2:

    DD84270022E57F1850C8454FA432ADFF99588157B|index.docbook|2225|Redhat 7.3 (32bit)|Linux

D84270022E57F1850C8464F5432ADFF99588157B|index.docbook|2225|Redhat 8.0 (32bit)|Linux

26EEEB25D7005F9FF9EE05A8084C77242702FBAD|Localizable.strings|2142|Mac OS X 10.4|OSX

34DC3D728C34E32F090307F575254D57E53C53FF|SYSTEM|10747904|Windows 7 Home Premium (32bit)|Windows

279E5A766C88EEA5AB946A0AF8D0C4FC366B2AF9|totem.devhelp|21324|Linux Ubuntu Desktop 9.10 (32bit)|Linux

279E5A766C88EEA5AB964A0AF8D0C4FC366B2AF9|totem.devhelp|21324|Linux Ubuntu Desktop 9.10 (64bit)|Linux

B3D11390AB8683BBE443A415EDD91BFDFD482134|dslconfig.pyc|6246|Redhat 9.0 (32bit)|Linux

Now you probably won’t find any immediate matches in these few lines, but I know that somewhere down the line there will be at least one match because I saw that while skimming through the files.

  • 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-07T04:24:10+00:00Added an answer on June 7, 2026 at 4:24 am

    you’re probably looking for something like this:

    use with() it automatically closes the files for you.

    def checkOS():
        with open("C:/Python/NSRLOS.txt") as fid1,open("C:/Python/sha_sub_hashes.out") as fid2,open("osMatches.txt", 'w') as outdata:
            for xline,yline in zip(fid1,fid2):  #zip fetches lines from both files one by one                                           
                xline= xline.split(',')[1]      #use itertools.izip instead of zip if you're on python 2.x
                yline = yline.split("|")[3]
                zline = xline.replace('"','')
                if yline == zline:                
                    outdata.write("{0}{1}\n".format(yline , zline)) #use write to write the data back
    
    if __name__=="__main__":
    checkOS()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having a bit of difficulty with this current code I have set
As a beginner in Ocaml, I have this current working code: ... let ch_in
if (webBrowser1.Url.AbsoluteUri == www.google.com) { label9.Text = webBrowser1.Url.AbsoluteUri; } This is my current code.
My current code is this $swift = email::connect(); $swift->setSubject('hello') ->setFrom(array('alex@example.com.au' => 'Alex')) ->setTo(array('alex@example.com.au' =>
This is my current search code. -(void)filterContentForSearchText:(NSString *)searchText scope:(NSString *)scope { [filteredList removeAllObjects]; for(Location
This question is related to a previous question of mine That's my current code
I'm running code that sometimes yields this: UInt32 current; int left, right; ... //sometimes
The code i current have is this. function update (){ latest_id = $('#image:first').data('position'); /*
This is my current scenario: I have checked in my grails app code +
Take this scenario. I have a Google Analytics tracking code, and I only 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.