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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T20:25:01+00:00 2026-05-14T20:25:01+00:00

Trying to write a code that searches hash values for specific string’s (input by

  • 0

Trying to write a code that searches hash values for specific string’s (input by user) and returns the hash if searchquery is present in that line.

Doing this to kind of just learn python a bit more, but it could be a real world application used by an HR department to search a .csv resume database for specific words in each resume.

I’d like this program to look through a .csv file that has three entries per line (id#;applicant name;resume text)

I set it up so that it creates a hash, then created a string for the resume text hash entry, and am trying to use the .find() function to return the entire hash for each instance.

What i’d like is if the word “gpa” is used as a search query and it is found in s[‘resumetext’] for three applicants(rows in .csv file), it prints the id, name, and resume for every row that has it.(All three applicants)

As it is right now, my program prints the first row in the .csv file(print resume[‘id’], resume[‘name’], resume[‘resumetext’]) no matter what the searchquery is, whether it’s in the resumetext or not.

lastly, are there better ways to doing this, by searching word documents, pdf’s and .txt files in a folder for specific words using python (i’ve just started reading about the re module and am wondering if this may be the route, rather than putting everything in a .csv file.)

def find_details(id2find):
    resumes_f=open("resume_data.csv")
    for each_line in resumes_f:
        s={}
        (s['id'], s['name'], s['resumetext']) = each_line.split(";")
        resumetext = str(s['resumetext'])
        if resumetext.find(id2find):
            return(s)
        else:
            print "No data matches your search query. Please try again"

searchquery = raw_input("please enter your search term")
resume = find_details(searchquery)
if resume:
    print resume['id'], resume['name'], resume['resumetext']
  • 1 1 Answer
  • 1 View
  • 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-05-14T20:25:02+00:00Added an answer on May 14, 2026 at 8:25 pm

    The line

    resumetext = str(s['resumetext'])
    

    is redundant, because s['resumetext'] is already a string (since it comes as one of the results from a .split call). So, you can merge this line and the next into

    if id2find in s['resumetext']: ...
    

    Your following else is misaligned — with it placed like that, you’ll print the message over and over again. You want to place it after the for loop (and the else isn’t needed, though it would work), so I’d suggest:

    for each_line in resumes_f:
        s = dict(zip('id name resumetext'.split(), each_line.split(";"))
        if id2find in s['resumetext']:
            return(s)
    print "No data matches your search query. Please try again"
    

    I’ve also shown an alternative way to build dict s, although yours is fine too.

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

Sidebar

Ask A Question

Stats

  • Questions 507k
  • Answers 507k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I'm not sure how to configure a FluorineFx server. I… May 16, 2026 at 3:56 pm
  • Editorial Team
    Editorial Team added an answer In my opinion, that RPG tutorial you mention has a… May 16, 2026 at 3:56 pm
  • Editorial Team
    Editorial Team added an answer char* query = "SELECT * FROM table WHERE LOWER(notes) LIKE… May 16, 2026 at 3:56 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I'm trying to write a code that allows a user to load an assembly
I'm trying to write some code that uses Numpy. However, I can't import it:
Right now I am trying to use selenium ide to write code that makes
I'm trying to write a method that interpolates from 0 to x (position of
I am trying to write some c# code to start a browser using Process.Start(app,args);
I'm trying to write a helper class that represents fields on an object. The
I am trying to write a unit test using .NET 4 to ensure that
I am trying to write a server application that listens to both IPv6 and
I have a txt file that has a change-log.I'm trying to display the new
In trying to write a simple C# ADO.NET application to connect to my database

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.