Importing iPhone Contacts

(YOUR PROFITS ARE LEAKING: Critical Flaws Found On Your Website)
m (Reverted edits by 212.34.150.83 (Talk) to last revision by sixwheeledbeast)
 
Line 6: Line 6:
# Run securedContacts, and download the resulting csv file on your PC.
# Run securedContacts, and download the resulting csv file on your PC.
-
URGENT NOTIFICATION:
+
== contact.py ==
-
+
 
-
Our industry analysis reveals that 97% of websites have CATASTROPHIC SEO errors.  
+
The following code will take the output csv file and transfer it into one large vcf file which you can import using the Contacts application on your [[Nokia N900|N900]]. One drawback to using the securedContacts seems to be that any location information is lost, but I found this import a million times better than doing it by hand. Just copy the code into a new file "contact.py" and then rename your csv along side it as "contacts.csv".
-
   
+
 
-
Imagine: your target audience is searching for your services, but they're ONLY finding YOUR COMPETITORS. RIGHT NOW.  
+
You can run the code with:
-
+
  python contact.py > contacts.vcf
-
Every day of inaction means:  
+
 
-
+
<source lang="python">
-
Burning through your ad budget
+
#!/usr/bin/env python
-
Flushing potential revenue down the drain
+
import re
-
Strengthening your competitors
+
import datetime, time
-
+
fh = open('contacts.csv','r')
-
STOP THE BLEEDING: Click here for a FREE audit + expert consultation: https://boostmysite.net/  
+
objectlist = []
-
+
class contact:
-
Your website should be a SALES MACHINE, not a Black Hole for your money!  
+
def __init__(self,first,last):
-
+
self.last = last
-
The time to act is NOW or NEVER. While you're reading this, your competitors have already fixed their errors and are snapping up YOUR customers.  
+
self.first = first
-
+
self.details={}
-
The Boostmysite.net Team
+
 +
def update(self,detail):
 +
value = detail.replace(" ","")
 +
value = value.strip('\n')
 +
homenum = re.compile("^[0-9]{8}$")
 +
mobnum = re.compile("^[0-9]{10}$")
 +
mobnum2 = re.compile("^\+[0-9]{11}$")
 +
email = re.compile("^.*@.*$")
 +
 +
if homenum.search(value):
 +
self.details['TEL;TYPE=HOME,VOICE:']=value
 +
elif mobnum.search(value):
 +
self.details['TEL;TYPE=MOBILE,VOICE:']=value
 +
elif mobnum2.search(value):
 +
self.details['TEL;TYPE=MOBILE,VOICE:']=value
 +
elif email.search(value):
 +
self.details['EMAIL;TYPE=PREF,INTERNET:']=value
 +
def check(self,first,last):
 +
return first == self.first and last == self.last
 +
 
 +
 
 +
for i in fh:
 +
line = i.replace("\n","")
 +
last,first,detail = i.split(';')
 +
 +
for i in objectlist:
 +
if i.check(first,last):
 +
i.update(detail)
 +
break
 +
else:
 +
obj = contact(first,last)
 +
obj.update(detail)
 +
objectlist.append(obj)
 +
 
 +
for i in objectlist:
 +
print "BEGIN:VCARD"
 +
print "VERSION:3.0"
 +
print "N:"+i.last+";"+i.first
 +
print "FN:"+i.first+" "+i.last
 +
for j, v in i.details.items():
 +
print j+v
 +
now = datetime.datetime
 +
n = now.now()
 +
print "REV:"+str(n.year)+str(n.month).zfill(2)+str(n.day).zfill(2)+"T"+str(n.hour).zfill(2)+str(n.minute).zfill(2)+str(n.second).zfill(2)+"Z"
 +
print "END:VCARD"
 +
</source>
 +
 
 +
After your vcf file is generated, you can place it onto your n900, then in the Contacts application, click the title bar >>> "Get contacts" >>> Import Contacts". Browse to your contacts.vcf file and click import!
 +
 
 +
Hope this helps someone, this code was pretty rushed and got the job done for me. Phone number regexps worked for my Australian phone numbers, you may have to make changes for overseas numbers.
 +
 
 +
[[Category:HowTo]]
 +
[[Category:Power users]]

Latest revision as of 09:29, 20 May 2025

[edit] Import how to

To import data, we first need to jailbreak the iPhone. There are many tutorials for this on the net. After jailbreaking, ensure that you have the package "Cydia" installed (usually included by default).

  1. From Cydia, install securedContacts (from the BigBoss repository)
  2. Run securedContacts, and download the resulting csv file on your PC.

[edit] contact.py

The following code will take the output csv file and transfer it into one large vcf file which you can import using the Contacts application on your N900. One drawback to using the securedContacts seems to be that any location information is lost, but I found this import a million times better than doing it by hand. Just copy the code into a new file "contact.py" and then rename your csv along side it as "contacts.csv".

You can run the code with:

python contact.py > contacts.vcf
#!/usr/bin/env python
import re
import datetime, time
fh = open('contacts.csv','r')
objectlist = []
class contact:
	def __init__(self,first,last):
		self.last = last
		self.first = first
		self.details={}
 
	def update(self,detail):
		value = detail.replace(" ","")
		value = value.strip('\n')
		homenum = re.compile("^[0-9]{8}$")
		mobnum = re.compile("^[0-9]{10}$")
		mobnum2 = re.compile("^\+[0-9]{11}$")
		email = re.compile("^.*@.*$")
 
		if homenum.search(value):
			self.details['TEL;TYPE=HOME,VOICE:']=value
		elif mobnum.search(value):
			self.details['TEL;TYPE=MOBILE,VOICE:']=value
		elif mobnum2.search(value):
			self.details['TEL;TYPE=MOBILE,VOICE:']=value
		elif email.search(value):
			self.details['EMAIL;TYPE=PREF,INTERNET:']=value
	def check(self,first,last):
		return first == self.first and last == self.last
 
 
for i in fh:
	line = i.replace("\n","")
	last,first,detail = i.split(';')
 
	for i in objectlist:
		if i.check(first,last):
			i.update(detail)
			break
	else:
		obj = contact(first,last)
		obj.update(detail)
		objectlist.append(obj)
 
for i in objectlist:
	print "BEGIN:VCARD"
	print "VERSION:3.0"
	print "N:"+i.last+";"+i.first
	print "FN:"+i.first+" "+i.last
	for j, v in i.details.items():
		print j+v
	now = datetime.datetime
	n = now.now()
	print "REV:"+str(n.year)+str(n.month).zfill(2)+str(n.day).zfill(2)+"T"+str(n.hour).zfill(2)+str(n.minute).zfill(2)+str(n.second).zfill(2)+"Z"
	print "END:VCARD"

After your vcf file is generated, you can place it onto your n900, then in the Contacts application, click the title bar >>> "Get contacts" >>> Import Contacts". Browse to your contacts.vcf file and click import!

Hope this helps someone, this code was pretty rushed and got the job done for me. Phone number regexps worked for my Australian phone numbers, you may have to make changes for overseas numbers.