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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T16:58:55+00:00 2026-06-07T16:58:55+00:00

I have this code to check indexes in a file to see if they

  • 0

I have this code to check indexes in a file to see if they match, but to start off I am having trouble being able to select an index. What do I have to do in order to be able to do so, because at this moment it doesn’t show the values as being in a list.

def checkOS():
    fid = open("C:/Python/NSRLOS.txt", 'r')
    fhand = open("C:/Python/sha_sub_hashes.out", 'r')
    sLine = fhand.readline()
    line = fid.readline()
    outdata = []
    print line
checkOS()

Right now it prints:

"190","Windows 2000","2000","609"

I only want it to print: (so index[0])

190

And when I try index[0], I just get ' " '. So the first value in the whole string, I want a list to be able to select the index.

  • 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-07T16:58:57+00:00Added an answer on June 7, 2026 at 4:58 pm

    Try using line.split(",") to split the line by the commas, then strip out the quotation marks by slicing the result.

    Example:

    >>> line = '"190","Windows 2000","2000","609"'
    >>> sliced = line.split(',')
    >>> print sliced
    ['"190"', '"Windows 2000"', '"2000"', '"609"']
    >>> first_item = sliced[0][1:-1]
    >>> print first_item
    190
    

    …and here’s the whole thing, abstracted into a function:

    def get_item(line, index):
        return line.split(',')[index][1:-1]
    

    (This is assuming, of course, that all the items in the line are divided by commas, that they’re all wrapped by quotation marks, that there’s no spaces after the commas (although you could take care of that by doing item.strip() to remove whitespace). It also fails if the quoted items contains commas, as noted in the comments.)

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

Sidebar

Related Questions

i have this code to check for group membership but it seems to be
Hey so i have this code where i check to see if a player
I have written this code to check for a particular string from a file.
Hi all I have this code to check if an item from a textbox
i have this code that will check the array contains the specific string and
I have this code that will check for if the class more-results are in
I have this piece of code which check the last customer_id from the db.
I have this code to set up and check a cookie, and before a
I have this code : String check=SELECT COUNT(*) as check FROM recordstudent WHERE STUDENT_ID=+T_STUDENT_ID+
i have this code in c# doc.SelectSingleNode(WhoisRecord/registrant/email).InnerText how can i check whether it is

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.