0

We are to search collection and find businesses in the county from countyToSearch. Save the name, full address, county and state to saveLocation1

How it is currently is not correct. I dont really understand the filter()

def FindBusinessBasedOnCounty(countyToSearch, saveLocation1, collection):

    c = collection.filter(lambda user: user['county'] == countyToSearch)
  
    f = open(saveLocation1, 'w')
    for bus in c:
       f.write(bus["Name"] + "$" + bus["FullAddress"] + "$" + bus["County"] + "$" + bus["State"] + "\n")
       f.close()

edit: I want the result to be the rows in database, where the countyname is equal to countyToSearch.

qca
  • 1
  • 1

1 Answers1

0

I do not see you collection example, but what I see is :

  1. filter should be used as:

    c = filter(lambda user: user['county'] == countyToSearch, collection)
    
  2. you have uppercase County and lower case county.

  3. In addition, you have to use with open(..) and not open() ... close()

Lior Cohen
  • 5,570
  • 2
  • 14
  • 30