text: #!/usr/bin/python
  
  import os
  import csv
  from operator import itemgetter
  from collections import Counter
  from prettytable import PrettyTable
  
  # XXX: Place your "Outlook CSV" formatted file of connections from
  # http://www.linkedin.com/people/export-settings at the following
  # location: resources/ch03-linkedin/my_connections.csv
  
  CSV_FILE = os.path.join("private", 'linkedin-connections.csv')
  
  transforms = [
      ('Sr.', 'Senior'),
      ('Sr', 'Senior'),
      ('Jr.', 'Junior'),
      ('Jr', 'Junior'),
      ('CEO', 'Chief Executive Officer'),
      ('COO', 'Chief Operating Officer'),
      ('CTO', 'Chief Technology Officer'),
      ('CFO', 'Chief Finance Officer'),
      ('VP', 'Vice President'),
      ]
  
  csvReader = csv.DictReader(open(CSV_FILE), delimiter=',', quotechar='"')
  contacts = [row for row in csvReader]
  
  # Read in a list of titles and split apart
  # any combined titles like "President/CEO."
  # Other variations could be handled as well, such
  # as "President & CEO", "President and CEO", etc.
  
  titles = []
  for contact in contacts:
      titles.extend([t.strip() for t in contact['Job Title'].split('/')
                    if contact['Job Title'].strip() != ''])
  
  # Replace common/known abbreviations
  
  for i, _ in enumerate(titles):
      for transform in transforms:
          titles[i] = titles[i].replace(*transform)
  
  # Print out a table of titles sorted by frequency
  
  pt = PrettyTable(field_names=['Title', 'Freq'])
  pt.align = 'l'
  c = Counter(titles)
  [pt.add_row([title, freq])
   for (title, freq) in sorted(c.items(), key=itemgetter(1), reverse=True)
       if freq > 1]
  print pt
  
  # Print out a table of tokens sorted by frequency
  
  tokens = []
  for title in titles:
      tokens.extend([t.strip(',') for t in title.split()])
  pt = PrettyTable(field_names=['Token', 'Freq'])
  pt.align = 'l'
  c = Counter(tokens)
  [pt.add_row([token, freq])
   for (token, freq) in sorted(c.items(), key=itemgetter(1), reverse=True)
       if freq > 1 and len(token) > 2]
  print pt