Created
June 26, 2019 10:20
-
-
Save awg01/f3fe974bb64618e7221a84edb5a56c89 to your computer and use it in GitHub Desktop.
I want to check whether city name 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)) | |
example_sent2 = "Anusandhan Bhawan, C-56/1, Sector-62,Allahabad - 201307 Uttar Pradesh (India)" | |
#print(random.choice(ct)) | |
for city in ct: | |
if search(city, example_sent2,): | |
print(search(city, example_sent2)) | |
break | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm able to match 1981 records but records(from csv file) after that are not matching with my given sentence.
Here's link of my CSV file
https://www.kaggle.com/sahilgandhi94/indian-pincodes/downloads/indian-pincodes.zip/1
Please download it.Its just few KB's.
Thank you in advance.