Skip to content

Simple gem for reading in contact CSV files that you can export from email clients like Outlook or GMail. Works with Outlook CSV (Windows) out of the box, but can be extended.

License

Notifications You must be signed in to change notification settings

guilherme/contact_csv

This branch is 2 commits ahead of mwhuss/contact_csv:master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

author
Guilherme Reis Campos
Feb 10, 2009
c5245d1 · Feb 10, 2009

History

7 Commits
Nov 18, 2008
Feb 10, 2009
Nov 18, 2008
Nov 18, 2008
Nov 18, 2008
Nov 18, 2008
Nov 18, 2008
Nov 18, 2008
Nov 18, 2008
Nov 21, 2008
Nov 18, 2008
Nov 18, 2008
Nov 18, 2008

Repository files navigation

ContactCsv

Supported CSV

  • Outlook 2003 CSV (Windows)

Reading in CSV

To import contacts you use a ContactManager…

contact_manager = ContactCsv::ContactManager.new
contact_manager.read(‘/path/to/file.csv’)
or
contact_manager.parse(‘csv,data,string’)

Getting the contacts

contact_manager.contacts.each do |contact|
puts contact.name
puts contact.email
puts contact.extras[‘Spouse’]
end

See the Contact class for a complete list of attributes.

Lookup Tables

A lookup table is used to map the csv columns to Contact class attributes. You can create your own lookup tables by using the LookupTable class and passing it in inside an array to the ContactManager class.

These are the column headers in the csv
headers = [“First Name”,“Last Name”,“Email Address”]

These map the column headers to the attribute of the Contact class
legend = {
‘First Name’ => :first_name,
‘Last Name ’ => :last_name,
’Email Address’ => :email
}

lookup_table = LookupTable.new(headers, legend)
contact_manager = ContactCsv::ContactManager.new([lookup_table])
or
contact_manager.lookup_tables << lookup_table

If you think you have composed a good lookup table email it to me (mwhuss@gmail.com) and I will include it in the gem.

To Do

  • Add lookup table for Outlook 2003 CSV (DOS)
  • Add lookup table for GMail CSV

About

Simple gem for reading in contact CSV files that you can export from email clients like Outlook or GMail. Works with Outlook CSV (Windows) out of the box, but can be extended.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 67.2%
  • JavaScript 32.8%