Last active
May 27, 2024 04:33
-
-
Save Animeshz/1baf34d7afd6d7db9acce393497b25bf to your computer and use it in GitHub Desktop.
IIITL Contact Extract (Unofficial WhatsApp Group)
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 | |
import difflib | |
import io | |
import re | |
import requests | |
SHEET_URL = 'https://docs.google.com/spreadsheets/d/1PIVUewR8OE9LHSoEvpH6jEoaDvd3TpH2t3ryZwptxJs/edit#gid=561315341' | |
BRANCHES = ['CSAI', 'CSB', 'CS', 'IT'] | |
if __name__ == '__main__': | |
reader = csv.DictReader(io.StringIO(requests.get(SHEET_URL.replace('/edit#gid=', '/export?format=csv&gid=')).text)) | |
for row in reader: | |
name = row['Name'].strip().title() | |
number = row['Whatsapp Number'].strip().lstrip('0') | |
email = row['Email address'].strip() | |
allotted_branch = re.sub('AND|\+', ' ', row['Allotted Branch'].strip().upper()).rstrip('E') | |
if not re.match('\+?[-\d\s]+', number): | |
continue | |
first_name, _, last_name = name.rpartition(' ') | |
if '+' not in number: | |
number = '0' + number | |
if ' ' in allotted_branch: | |
allotted_branch = ''.join([word[0] for word in allotted_branch.split()]) | |
try: | |
allotted_branch = difflib.get_close_matches(allotted_branch, BRANCHES)[0] | |
except: | |
continue | |
print('BEGIN:VCARD') | |
print('VERSION:2.1') | |
print(f'N:(IIITL|{allotted_branch});{first_name};{last_name};;') | |
print(f'FN:{name} (IIITL|{allotted_branch})') | |
print(f'TEL;CELL;PREF:{number}') | |
print(f'EMAIL;HOME:{email}') | |
print('END:VCARD') |
Can use termux
in android if do not have laptop/pc to run python.
to export the python file
wget https://gist.githubusercontent.com/Animeshz/1baf34d7afd6d7db9acce393497b25bf/raw/851cb6d1e82bc5f2fcc5530190f33a5d1fed05ca/contact-extract.py
Or just (without downloading python script, direct export).
curl -L https://gist.github.com/Animeshz/1baf34d7afd6d7db9acce393497b25bf/raw | python3 > iiitl-freshers.vcf
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage: Save in
.vcf
file and import into contacts app.python3 contact-extract.py > iiitl-freshers.vcf