Last active
April 23, 2017 20:54
Star
You must be signed in to star a gist
Python script to find emails in bio and update followers csv exported from picodash.com
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
#!/usr/bin/python | |
import sys | |
import csv | |
import re | |
try: | |
filename = sys.argv[1] | |
except: | |
print "\nERROR: Please specify filename\n" | |
print "Usage:" | |
print " $ picodash_export_bioemail.py data.csv\n" | |
print "- First param should be the csv file path\n" | |
sys.exit(0) | |
new_data=[] | |
# open csv file to find emails | |
with open(filename, 'r') as csvfile: | |
csv_reader = csv.reader(csvfile) | |
# iterate on all rows in csv | |
for row_index,row in enumerate(csv_reader): | |
# find the index of bio column | |
if row_index == 0: | |
BIO_COL_NUM = None | |
for col_index,col in enumerate(row): | |
if col == "bio": | |
BIO_COL_NUM = col_index | |
row.append("email") | |
new_data.append(row) | |
continue | |
# check if bio exists and find emails in rows | |
bio = row[BIO_COL_NUM] | |
if bio != '': | |
emails = re.findall(r'[\w\.-]+@[\w\.-]+', bio) | |
row.append(",".join(emails)) | |
new_data.append(row) | |
if emails: | |
print "Found email: "+(','.join(emails)) | |
else: | |
row.append("") | |
new_data.append(row) | |
with open(filename, 'w') as csvfile: | |
csv_writer = csv.writer(csvfile, lineterminator='\n') | |
csv_writer.writerows(new_data) | |
print "Updated CSV with location column: " + filename |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is a Python script to add emails column (from bio description) in csv for followers exported from picodash.com
You have to specify the csv_filename. The script will add a new column "email" and add emails found in the bio description
Usage:
/usr/bin/python picodash_export_bioemail.py <csv_filename>
Example:
/usr/bin/python picodash_export_bioemail.py data.csv