{"id":13,"date":"2014-07-15T11:39:00","date_gmt":"2014-07-15T11:39:00","guid":{"rendered":""},"modified":"2016-02-25T18:09:01","modified_gmt":"2016-02-25T18:09:01","slug":"extracting-names-from-email-addresses","status":"publish","type":"post","link":"https:\/\/www.root42.de\/blog\/?p=13","title":{"rendered":"Extracting Names from Email Addresses"},"content":{"rendered":"<p>Given a CSV file with the following format: <\/p>\n<pre><br \/>;;firstname.lastname@somehost.com<br \/><\/pre>\n<p> The task is to extract the names from the email addresses. We assume that the names are seperated by periods (.) and that all the names are supposed to be capitalized and printed with strings:  <\/p>\n<pre><br \/>#!\/usr\/bin\/env python<br \/><br \/>import sys<br \/><br \/>if len( sys.argv ) < 2:<br \/>    print \"Usage: %s filename\" % sys.argv[ 0 ]<br \/>    sys.exit( 1 )<br \/><br \/>textFileName = sys.argv[ 1 ]<br \/>textFile = open( textFileName, \"r\" )<br \/><br \/>for line in textFile:<br \/>    fields = line.strip().split( ';' )<br \/>    email = fields[ 2 ].split( \"@\" )<br \/>    emailName = email[ 0 ].split( '.' )<br \/>    capitalizedName = [ x[:1].upper() + x[1:].lower() for x in emailName ]<br \/>    print '%s;%s;%s' % ( capitalizedName[ 0 ], ' '.join( capitalizedName[ 1: ] ), fields[ 2 ] )<br \/><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Given a CSV file with the following format: ;;firstname.lastname@somehost.com The task is to extract the names from the email addresses. We assume that the names are seperated by periods (.) and that all the names are supposed to be capitalized and printed with strings: #!\/usr\/bin\/env pythonimport sysif len( sys.argv ) < 2: print \"Usage: %s &hellip; <a href=\"https:\/\/www.root42.de\/blog\/?p=13\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Extracting Names from Email Addresses&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[7,15],"tags":[],"_links":{"self":[{"href":"https:\/\/www.root42.de\/blog\/index.php?rest_route=\/wp\/v2\/posts\/13"}],"collection":[{"href":"https:\/\/www.root42.de\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.root42.de\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.root42.de\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.root42.de\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=13"}],"version-history":[{"count":1,"href":"https:\/\/www.root42.de\/blog\/index.php?rest_route=\/wp\/v2\/posts\/13\/revisions"}],"predecessor-version":[{"id":197,"href":"https:\/\/www.root42.de\/blog\/index.php?rest_route=\/wp\/v2\/posts\/13\/revisions\/197"}],"wp:attachment":[{"href":"https:\/\/www.root42.de\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=13"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.root42.de\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=13"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.root42.de\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=13"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}