extract 5 digit zipcode numbers from tweets

Q & ACategory: Questionsextract 5 digit zipcode numbers from tweets
subrina asked 4 years ago

i am new to python. i have a data of thousand tweets which contain 5 digit zipcode numbers and also other meaningless numbers within the tweet. these tweets are associated with latitude and longitude information. i need to extract 5 digit ZIPCode numbers (and ignore other numbers that are not 5 digit) from those tweets. then make 3 columns for lat/long /zipcodes. can you please help me with that? Thanks Subrina

Matt Payne replied 4 years ago

It would be helpful to have some (or all) of your dataset online, please. Could you put it on github? Thanks

832 Answers
@westurner answered 4 years ago

A few jupyter notebooks to show how to:
Mining the Social Web 2nd Edition
– Chapter 1: Mining Twitter https://github.com/ptwobrussell/Mining-the-Social-Web-2nd-Edition/blob/master/ipynb/__Chapter%201%20-%20Mining%20Twitter%20(Full-Text%20Sampler).ipynb
– Chapter 9: Twitter Cookbook ttps://github.com/ptwobrussell/Mining-the-Social-Web-2nd-Edition/blob/master/ipynb/Chapter%209%20-%20Twitter%20Cookbook.ipynb
Python Data Science Handbook:
– Chapter 3: Data Manipulation with Pandast tps://github.com/jakevdp/PythonDataScienceHandbook#3-data-manipulation-with-pandas
Python docs:
– import re; re? # IPython ($ pydoc re)
– https://docs.python.org/2/library/re.html#re.findall
Mapping, Lat/Long, GeoJSON [-LD]:
https://github.com/python-visualization/folium (Leaflet.js maps (optionally w/ Jupyter notebook))
http://www.simplekml.com/en/latest/ (KML XML)
Pandas, Twitter:

subrina answered 4 years ago

Thank you so much for your reply
the data is like:
City of Sun Valley 91352…City of Sun Valley 91352…..8911 Driftstone Dr, Spring, TX 77379….Battery at 10601-10698…….
these are the tweets.  i wanna extract only the 5 digit ZIPCodes in one column. tried the following:
   zipcode=csv.reader(csvfile,delimiter=’ ‘, quotechar=’|’)    
    for row in zipcode:
        re.findall(r'(\d{5})’, str(row))
it gives me result like:
column 1:           [‘91352’] [‘91352’]  [‘77379’]”[‘10601’
column 2:           ‘10698’]” [‘91352’] [‘91352’] 
plz look at the 2nd column where the zipcode 10601-10698 divided into 2 column. i want each of the zipcodes in the same column but in the same row under zipcode name.



Just posted a photo @ City of Sun Valley 91352 https://t.co/F1br8SFo8j

Just posted a photo @ City of Sun Valley 91352 https://t.co/tXR3ynr9K1

8911 Driftstone Dr, Spring, TX 77379, $174,750 4 beds, 2 baths https://t.co/w6Kjnur90V

Just posted a photo @ City of Sun Valley 91352 https://t.co/hakE3Zfy9t

subrina replied 4 years ago

plz ignore the bottom texts. that was uploaded accidently.

Payday Loans answered 3 years ago

lender loans no credit loan money online [url=https://cashnow.cars]payday lender[/url]

ingextenror answered 3 years ago

real money casino online gambling casino huuuge casino slots online casino slots no download | [url=https://onlinecasinousa.gb.net/]vegas world casino games[/url] [url=https://onlinecasinousa.gb.net/]online casino games free[/url]

HilsSisaEpittee answered 3 years ago

weight loss for women best diets for weight loss unexplained weight loss weight loss for women | [url=https://weightlosskeyz.com/]best diets for weight loss[/url] [url=https://weightlosskeyz.com/]hypnosis for weight loss[/url]

friemiachime answered 3 years ago

virgin online casino tropicana online casino virgin online casino best online casinos | [url=https://onlinecasinoplayusa.us.org/]borgata online casino[/url] [url=https://onlinecasinoplayusa.us.org/]online casino bonus[/url]

torMictrehego answered 3 years ago

free slots online online slot games gsn casino slots free slots casino games | [url=https://onlinecasinoslotsy.us.org/]free online slots games[/url] [url=https://onlinecasinoslotsy.us.org/]vegas slots free[/url]

setignomone answered 3 years ago

play casino zone online casino free online casino online casinos for us players | [url=https://onlinecasinokle.com/]play online casino[/url] [url=https://onlinecasinokle.com/]online casino gambling[/url]

SerAroniaCani answered 3 years ago

casino games online casino real money best online casino casino blackjack | [url=https://onlinecasinodd.com/]online casinos for us players[/url] [url=https://onlinecasinodd.com/]free online casino slots[/url]

Mitephext answered 3 years ago

low carb diet keto diet plan for beginners keto diet apple cider vinegar diet | [url=https://ketodietix.com/]ketone diet[/url] [url=https://ketodietix.com/]shepherds diet[/url]

setignomone answered 3 years ago

hollywood casino free slots mohegan sun free online slots vegas free slots online da vinci diamonds free online slots | [url=https://onlinecasino777.gb.net/]hollywood casino free slots online[/url] [url=https://onlinecasino777.gb.net/]casino slots free games[/url]

Mitephext answered 3 years ago

casino online slots online casino games free gsn casino games sugarhouse casino online | [url=https://onlinecasino888.us.org/]gambling online[/url] [url=https://onlinecasino888.us.org/]double down casino[/url]

Mypephypota answered 3 years ago

casino blackjack casino games free online casino slots online gambling | [url=https://casinorealmoneyigames.com/]online casino real money[/url] [url=https://casinorealmoneyigames.com/]mgm online casino[/url]

Cash Advance answered 3 years ago

personal loan no credit check installment loans no credit check payday loans no credit check [url=https://loansnocreditcheck.shop]personal loans no credit check[/url]

Loans answered 3 years ago

calculate interest on loan no credit check lenders only no fax payday loans [url=https://paydayloan2018.us.com]instant payday loans[/url]

lypecellile answered 3 years ago

online casino real money casino slots virgin online casino mgm online casino | [url=https://onlinecasinoist.com/]parx online casino[/url] [url=https://onlinecasinoist.com/]zone online casino[/url]

Hininuamp answered 3 years ago

online casino sites virgin online casino online casino gambling casino online slots | [url=https://onlinecasinoxplay.us.org/]online casinos for us players[/url] [url=https://onlinecasinoxplay.us.org/]casino online slots[/url]

1 2 3 34 Next »
Your Answer

3 + 9 =