Created
June 26, 2019 09:35
-
-
Save awg01/68a269277d4deb7eb1d8166f4506ca72 to your computer and use it in GitHub Desktop.
I want to whether the cityname(from csv file) is present in given sentence.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
from re import search | |
#example_sent2 = "Sunset is the time of day when our sky meets the outer space solar winds. There are blue, pink, and purple swirls, spinning and twisting, like clouds of balloons caught in a whirlwind. The sun moves slowly to hide behind the line of horizon, while the moon races to take its place in prominence atop the night sky. People slow to a crawl, entranced, fully forgetting the deeds that must still be done. There is a coolness, a calmness, when the sun does set..XYZ, Example Exports as my Post Office Box 924 Yavatmal - 445001 INDIA.Ram is a very good student." | |
pin = [] | |
ct = [] | |
#for loading csv file into list | |
with open('pincode_final.csv',"r") as csvfile: | |
csv_f = csv.reader(csvfile) | |
for row in csv_f: | |
pin.append(row[0]) #for future use | |
ct.append(row[1]) #etc for all columns | |
print(len(ct)) | |
matches = [] | |
#example_sent2 = "Anusandhan Bhawan, C-56/1, Sector-62,Allahabad - 201307 Uttar Pradesh (India)" | |
example_sent2 = "Anusandhan Bhawan, C-56/1, Sector-62, Bhadohi - 201307 Uttar Pradesh (India)" | |
#print(random.choice(ct)) | |
for city in ct: | |
if search(r'\b{}\b'.format(city), example_sent2): | |
print(search(r'\b{}\b'.format(city), example_sent2)) | |
break | |
#print(matches) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://www.kaggle.com/sahilgandhi94/indian-pincodes/downloads/indian-pincodes.zip/1
Here's the csv file.
The problem is I'm able to search upto 1981 records but after I am getting error.