Script to import contacts from CSV file into Address Book

Hi,
I am wondering if it would be possible to import contacts from a CSV file into a group in Address Book using applescript, and if so, if anyone is aware of a script that does this or something similar.
I have a CSV file with three columns 'First Name', 'Last Name' and 'Email Address'.  I would like these to correspond with  'First', 'Last' and (Work) 'Email' in Address Book.
Ideally the script would also check to see if entries already exist for the people being imported, but this is less crucial.
Thanks in advance for any assistance,
Nick

Hi,
Test this on a very small csv file (four or five contacts) to see if it works for you. It will not de-duplicate. You don't give the name of the group, so you'll need to replace Name of group in the second line with your group name, enclosed in double quotes.
--begin script
set the_people to read (choose file with prompt "Choose your CSV file")
set the_group to "Name of group"
set old_tids to AppleScript's text item delimiters
set AppleScript's text item delimiters to ","
set par_count to (count paragraphs in the_people)
repeat with x from 1 to par_count
          set next_par to paragraph x of the_people
          set first_name to text item 1 of next_par
          set last_name to text item 2 of next_par
          set e_mail to text item 3 of next_par
          tell application "Address Book"
                    set nu_person to make new person with properties {first name:first_name, last name:last_name}
  make new email at end of emails of nu_person with properties {label:"Work", value:e_mail}
                    add nu_person to group the_group
  save
          end tell
end repeat
set AppleScript's text item delimiters to old_tids
--end script
Watch out for bad line breaks in the lines beginning "set nu_person..." and "make new email..."

Similar Messages

  • I'm trying to import contacts from Outlook to mac address book. I've exported as a CSV but when i try to open with the Address book import tool, the file is greyed out and can't be imported

    I'm trying to import contacts from Outlook to Mac address book. I've exported as a CSV but when I try to open with the Address book import tool, the file is greyed out and can't be imported. Any ideas? 
    Thanks,
    Ian

    If you can't get the exported .csv file to work you might consider using Migration Assistant: http://support.apple.com/kb/HT2518, particular if you need to move more than just your contacts.  There is some granularity in the options on what to transfer but I'm not sure if you can choose to just your migrate contacts.

  • How to import data from CSV file into a table by using oracle forms

    Hi,
    I have a CSV file and i want to insert in oracle database in a table by using a button in oracle forms.
    the user can select CSV file by using open dialog .
    can any one help me to find method to make import and select file from the client machine ?
    thx.

    1. create table blob
    CREATE TABLE IB_LOVE
      DOC          BLOB,
      CONTRACT_NO  VARCHAR2(20 BYTE)                NOT NULL
    )2. use the code below to insert:
           INSERT INTO ordmgmt.ib_love
                       (contract_no, doc
                VALUES (:control.contract_no_input, NULL
           lb$result :=
             webutil_file_transfer.client_to_db (:b2.file_name, v_file_blob_name, v_col_blob_name,
                                                 'CONTRACT_NO = ' || :control.contract_no_input);
           :SYSTEM.message_level := 25;
           COMMIT;
           :SYSTEM.message_level := 0;3. use the code below to download
         if :control.CONTRACT_NO_INPUT is not null then
              vboolean :=   webutil_file_transfer.DB_To_Client_With_Progress(
                               vfilename,  --filename                       
                              'IB_LOVE', ---table of Blob item                       
                              'DOC',  --Blob column name                       
                              'CONTRACT_NO = ' || :CONTROL.CONTRACT_NO_INPUT, ---where clause to retrieve the record                       
                              'Downloading from Database', --Progress Bar title                       
                              'Wait to Complete'); --Progress bar subtitle  client_host('cmd /c start '||vfilename);
              client_host('cmd /c start '||vfilename);                 
         else
              errmsg('Please choose contract no');
         end if;4. use the code below to open file dialog
    x:= WEBUTIL_FILE.FILE_OPEN_DIALOG ( 'c:\', '*.gif', '|*.gif|*.gif|', 'My Open Window' ) ;
    :b2.FILE_NAME:=X;

  • How to import contacts from iPhone to Macbook Address Book...?

    Whenever I go under
    iTunes > Info > Sync Contacts
    It tries to import my empty contact list ON my mac to my iPhone, rather than import my iPhone contacts onto my Mac. How do I import my contacts into my address book?
    Please be specific, because from my previous research on how to do it.... it was a very vague explanation.
    Thank you!

    Without a unique contact in the macbook address book, it will delete all the contacts from the phone. You must have a unique contact in the macbook to trigger the merge response from iTunes when you go to sync. Also, make sure you take the time in iTunes preferences to put the checkmark where it says Prevent iPods, iPhones and iPads from syncing automatically. That way you have complete control over the sync process.

  • Problem importing CSV or tab-delimited file into Address Book

    I am trying to import a text file (tab delimited) or csv file into address book. The files are created in Excel and consist 8 columns with address info (first name, last name, street, city etc). For the sake of simplicity, the file only contains 2 records - so all in all 3 rows with data where the first row contains the headers as described above.
    I am perfectly able to import the fields first name, last name using Address Book's text import feature. However, as soon as I try to map Address Book's address field (Home, work or other) to my text file's headers, the import wizard stops responding. I can still scroll through the records with the left and right error, but the record count is screwed up ("-3 of 2") and clicking the OK button doesn't result in anything.
    So I am able to import the names but not the addresses - so I better rename the Address Book to Name Book
    Any clue of what's going wrong?

    I've been wrestling with the exact same problem. I have come to a solution, though serendipitously. The address variables belong to a group say address Office.
    1 - I creted a column with address Office which clued in AddressBook the the existence of the data for +address Other+ (and it assigned the columns ot the proper data)
    2 - address book does have an entry of address with all group elements of same colour, normally. I reassign address other to address office
    3 - I also assign address office (in right-hand column) to address office.
    At this point I have two groups of address office
    4 - I indicate to the second group 'do not import'
    5 - Then hit OK
    It seems that this loop is necessary to instantiate the proper group name to the group of variables. Why? who knows. Bad UI? Clearly. Apple engineers should've thought about it before? no kidding...

  • Importing .wab file into address book or anywhere else on my mac

    Hello all,
    I'm trying to import a Windows .wab file into Address Book (or anywhere else on my Mac for that matter) but can't find a way to make the two like eachother.
    I got the file from someone else and do not have a Windows computer to use in the process.
    Any suggestion would be most welcome!

    Unfortunately those files are in a format unknown to any Mac application. What you may try is this utility but I do not know that it will convert only the .wab file, but it's supposed to be able to convert Outlook data to an OS X readable format.
    In the future be aware that Outlook data files are incompatible with OS X. Have your Windows friends export their data files in a readable format such as Comma or Tab delimited text files.

  • How to import contacts from csv to Iphone 4S?

    How to import contacts from csv to Iphone 4S?

    Hi,
    you can use this app to import your contacts from CSV file to your iPhone:
    https://itunes.apple.com/us/app/contacts-in-import-csv-contacts/id549639443?mt=8
    You can send CSV file to app via email attachment ot iTunes. More details:
    http://csvcontacts.wordpress.com/user-instructions/
    You can handle phone number types correctly ("mobile","work","home"), import birdthays from any date format and many more.

  • Loading data from .csv file into Oracle Table

    Hi,
    I have a requirement where I need to populate data from .csv file into oracle table.
    Is there any mechanism so that i can follow the same?
    Any help will be fruitful.
    Thanks and regards

    You can use Sql Loader or External tables for your requirement
    Missed Karthick's post ...alredy there :)
    Edited by: Rajneesh Kumar on Dec 4, 2008 10:54 AM

  • Loading data from .csv file into existing table

    Hi,
    I have taken a look at several threads which talk about loading data from .csv file into existing /new table. Also checked out Vikas's application regarding the same. I am trying to explain my requirement with an example.
    I have a .csv file and I want the data to be loaded into an existing table. The timesheet table columns are -
    timesheet_entry_id,time_worked,timesheet_date,project_key .
    The csv columns are :
    project,utilization,project_key,timesheet_category,employee,timesheet_date , hours_worked etc.
    What I needed to know is that before the csv data is loaded into the timesheet table is there any way of validating the project key ( which is the primary key of the projects table) with the projects table . I need to perform similar validations with other columns like customer_id from customers table. Basically the loading should be done after validating if the data exists in the parent table. Has anyone done this kind of loading through the APEX utility-data load.Or is there another method of accomplishing the same.
    Does Vikas's application do what the utility does ( i am assuming that the code being from 2005 the utility was not incorporated in APEX at that time). Any helpful advise is greatly appreciated.
    Thanks,
    Anjali

    Hi Anjali,
    Take a look at these threads which might outline different ways to do it -
    File Browse, File Upload
    Loading CSV file using external table
    Loading a CSV file into a table
    you can create hidden items in the page to validate previous records before insert data.
    Hope this helps,
    M Tajuddin
    http://tajuddin.whitepagesbd.com

  • Import contacts from Google gmail into iPad2?

    How do I import contacts from Google gmail into the iPAD2?

    If you have push enabled it means emails are delivered to your phone instantly. So, instead of opening the app to check for mail your phone will buzz and bing when you get a new mail, as soon as it arrives in your mailbox.
    This is great for me as a business owner as it tells me the moment an email, which is possibly an enquiry arrives in my mailbox. Also means Im not constantly going into my mail looking for mail, it comes to me.
    This does reduce your battery life but ive not noticed much of a drain.
    Push also means any changes you make to your contacts either on the web or the phone are instantly pushed back. So, you could add a new contact on your computer in Gmail and voila! it appears on your phone in an instant.

  • How do i import my local csv files into HANA database as temporary tables  using java program?

    I want to import my local csv file into database for further apply Join with other tables programmatic in JAVA

    Hi Vivek,
    Please go through the following blogs and video to resolve your issue.
    Loading large CSV files to SAP HANA
    HANA Academy - Importing Data using CTL Method - YouTube
    Hope it helps.
    Regards
    Kumar

  • Can't import csv document into address book

    Hi folks, I can't import a csv document into address book. Just get a spinning wheel. I am an OSX 10.5.9 (Leopard) I exported a csv file from Excel then tried to import but nothing happens except a spinning wheel some times.
    Any thoughts?
    Thanks in advance.
    Ed Carreon
    http://www.carreonphotography.com

    You need to have setup your document with the appropriate fields for each piece of data, otherwise Address Book can't import it. If you take your current Address Book and export all the contacts as a single vCard file, then use this online tool (http://labs.brotherli.ch/vcfconvert/) to convert them to a CSV file, you can open the result in Excel or Pages to see how your document should be setup when you export it to CSV for importing into Address Book.

  • How do I import my contacts from iCloud onto my address book on my mac?

    How do I import my contacts from iCloud onto my address book on my mac?

    Hi veganqueen,
    If you already have your contacts in iCloud, you should be able to turn it on within the iCloud preference pane, as noted in the article below:
    OS X Yosemite: Change iCloud feature settings
    Regards,
    - Brenden

  • How do I move/copy contacts from Entourage to iCloud Address Book without creating duplicates? Address Book on Mac, iCloud, iPhone and iPad is now empty

    How do I move/copy contacts from Entourage to iCloud Address Book without creating duplicates? Address Book on Mac, iCloud, iPhone and iPad is now empty

    Thank you for letting me know!
    Going to give it a go. Had a back up of all my clients files stupidly not my software as I have the originals disks. Just realised that amongst the software is ibiz and have lost al my accounting and billing files for the last 7 years want to cry so losing my contacts now will really tip me over the edge!
    Fingerscrossed this works!

  • How to create power shell script to upload all termset csv files into the SharePoint2013 local taxonomy ?

    Hi Everyone,
    I want to create a powershell script file
    1) Check a directory and upload all termset csv files into the SharePoint local taxonomy.
    2) Input paramaters - directory that containss termset csv files, Local Termstore to import to,
    3) Prior to updating get a backup of the existing termstore (for rollback/recovery purposes)
    4) Parameters should be passed in via XML file.
    Please let me know how to do it.
    Regards,
    Srinivas

    Hi,
    Please check this link
    http://termsetimporter.codeplex.com/
    Please remember to click 'Mark as Answer' on the answer if it helps you

Maybe you are looking for