Archive

Archive for the ‘python’ Category

Python: how to transform the Thunderbird address book into a simple list of email addresses

January 2nd, 2010 No comments

Python is a high-level programming language interpreted, object oriented, suitable, Other uses, to develop distributed applications, scripting, and numerical computation.

Python programming language, consider a very powerful and versatile and that is why I used it to transform the address book of e-mail Mozilla Thunderbird in a list in a usable newsletter.

Here is my first screencast my blog so you can better understand what I mean, Click on the button-shaped square in the lower right of the video to the left of the volume to view full screen…Good vision and tell me what you think.

Get the Flash Player to see this content.

Code:


from string import *

def findrev(stro,strf,pos):
    i = pos
    while stro[i]!=strf:
        i = i - 1
    return i

fn = open("rubrica.csv")
fm = open("NewsLetter.txt","w")

while 1:
    line = fn.readline()
    if not line:
            break
    else:
            posc = find(line,"@",0)
            posv1 = find(line,",",posc)
            posv = findrev(line,",",posc)

            fm.writelines(line[posv+1:posv1]+','+'\n')

pass # do something

fm.writelines("bruni.marco@gmail.com")
fm.close()
fn.close()

print "Finito, ho creato la NewsLetter"