Most organisations have data in sources outside CiviCRM, such as previously used database platforms, spreadsheets created on the fly for specific events or other purposes, and email address books. Because manually entering large amounts of data can be tedious, CiviCRM provides a way do import data en masse if the source can export it into some common format such as a Comma Separated Version (CSV) file.
Imports can also be used to update existing data. This will be covered in the final section of this chapter.
For more details on how to think about your data before importing into CiviCRM, please read the section on "Organizing your data", especially "Mapping your data into CiviCRM".
Importing data requires considerable attention and care, so we'll present some concepts here that you should know before you start your first import. You can import both core and custom data for contacts, as well as data for event attendance, activities, memberships and contributions. This chapter will focus on the import process for contacts. The processes for other data are similar.
There are two ways to import data:
from CSV files. Most database and spreadsheet applications (e.g. OpenOffice.org Calc, Google Spreadsheets, Microsoft Excel) can create and manipulate files in this format. It is often easier to view and clean your data when it's in a CSV file than while it's still inside your old database.
Each column in your CSV file will map to a field in CiviCRM, so make sure you use a different column for every distinct bit of information.
Depending on your country or region, fields in your CSV files might be separated by semicolons (;) instead of commas. If so, you'll need to change the Import/Export Field Separator value in the CiviCRM Localization settings by going to the navigation menu and choosing Administer > Configure > Global Settings > Localization.
from another SQL or MySQL database stored on the same server, using an SQL query. (This option is only for advanced users who have a clear understanding of server and database administration.)
If you do not have a clear understanding of your existing data and how it will map to CiviCRM fields, you will experience frustrations and problems when you try to import the data. Please read about each type of data in other sections of this CiviCRM Manual and visit the CiviCRM online documentation for more information: http://wiki.civicrm.org/confluence/display/CRMDOC/Importing+Data
The following rules and recommendations will help you to import data with minimal problems:
When preparing your data import it is helpful to know what fields are required for Import. You'll want to be sure that these fields are included in your CSV import file. Below is a list of the required fields. They are marked red and starred in the interface. In case you have less data, selecting one field is enough. The External Identifier field is only useful if you want to update existing contacts. Please note that the field with the identifier (Match to Contact)is required for deduplication purposes.
Example of spreadsheet .csv format
When thinking about setting up your spreadsheet, think about the data that you are collecting and plan out your column headings. Keep in mind that you may need to create more than one .csv file and perform multiple imports before you are finished.
If you plan to import related data that pertains to a specific contact, e.g. event participant information, contribution data, etc., you will need to make sure that each contact record has a unique identifier or the contact record should have First Name, Last Name and Email, so that you can link their related data during later imports. If you have unique ID, you would map the ID to CiviCRM's External Identifier on import.
The import process has four steps.
Setup lets you specify the basic details of your import, including the source of the data. Data can come from either a CSV file, or an SQL query of a database on your server. A check-box lets you indicate whether the first row of your file contains column headers.
Note that imports use the default unsupervised rule to decide whether a contact record is a duplicate (refer to the Deduping and Merging chapter in this section for information on duplicate matching rules in CiviCRM). You can specify what action to take when an import encounters a duplicate:
Import mappings tell CiviCRM how the fields of data in your import file correspond to the fields in CiviCRM. The first time you import from a particular data source, it's a good idea to check the box to "Save this field mapping" at the bottom of the page before continuing. The saved mapping can then be easily reused the next time similar data is imported, by requesting that it be loaded at this step.
If you had column headings in your file, these headings will appear in the first column on the left-hand side of the Field Map, while the next two columns show two rows of data in your file to be imported, and the fourth column is the Matching CiviCRM Field. If you loaded an import mapping in Step 1, your choices will be reflected here. You can change them if they are inappropriate for this import.
The matching CiviCRM fields include standard CiviCRM data such as First Name and Last Name as well as any custom data fields that have been configured for use with contact records on your site. Match the fields by clicking the dropdown list and selecting the appropriate data. For example, if the heading of the second column in your input is Surname, you should choose Last Name as your Matching CiviCRM Field.
Select "- do not import -" for any columns in the import file that you don't want to import into CiviCRM.
If you have a saved mapping for a specific set of spreadsheet columns, and your spreadsheet layout has changed (for instance, you need to import additional fields, so you add the appropriate columns of data in the spreadsheet), you can modify and save the field mapping. One tip to ease the mapping process when you need to import additional fields is to place the additional columns of data in your import spreadsheet to the right of the columns you've previously mapped in CiviCRM. This allows you to use the existing saved field mapping to map the initial import fields, and then continue mapping the new data fields.
Note that if you add new data columns in your spreadsheet and do not position the columns AFTER the columns you previously mapped, you then can't use the saved mapping and will have to map all your import fields again.
Once you've mapped your fields, you can decide if you want to keep the original saved mapping unchanged, or check the box to "Update this field mapping" to include the new field mappings.
This screen previews the results of importing your data, reports the number of rows to be imported, and allows you to double check your field matches.
If some of the rows in your spreadsheet contain data that doesn't match CiviCRM's requirements for one or more fields, you'll see an error message with a count of the invalid rows (see the screenshot below). Click the Download Errors link and review the errors reported in the downloaded file, so you can fix them before doing the import.
At the bottom of the form, you can choose to add the contacts to an existing group, import to a new group, create a new tag, or tag imported records. Adding imported records to a separate group is strongly recommended in order to be able to quickly find the imports and, if necessary, delete and reimport them.
The final screen reports the successful imports along with Duplicate Contacts and Errors. If you have set the import to add all contacts to a Group or Tag, you can click through to see your imported contact records.
At this point it makes sense to check to make sure that your import has worked as expected. Search for the contacts that you just imported and examine their fields and custom data to make sure all is as expected.
We have just described the process of importing one data file. But what about if you want to import related data, like organizational addresses with employees, parent child relationships, activities, contributions, etc.? For each type of data you want to import, you will need to import a separate CSV file.
CiviCRM has specific tools for importing related contact data and a set of specific import tools for contributions, memberships, event participation etc. (and you should see specific chapters for details of how to use these tools). To import relationships, you should run multiple contact imports.
For example if we want to import data for children and then for both parents, we run three imports, one for the child, one for the father and one for the mother.
We first import the child remembering to include an external identifier that we can use to match the child to their parents. We then import the father, and then the mother, as related contacts, linking them to the child using the child's external identifier.
In the example below we have one CSV file which contains father and mother information. We use this CSV file twice as part of the import. Have a look at the fields below to understand what is happening.
We are linking the father to the original child using the external identifier and are then importing the related father name using the 'Child of' relationship type.
When the import is done, go back and verify the data by searching for the parent and examining the relationship tab. They should have a relationship linking them to the child.
You can then repeat this process for the mother, and also for other relationships as necessary.
For many organisations, an important element of cleaning your data is standardising addresses. In the US, this means conform to conventions defined by the United States Postal Service's Standards for Addresses. Standardising how addresses are entered into CiviCRM will allow for more accurate search results when searching by address, as CiviCRM can parse addresses based on the USPS standards if you choose to do so. To find out more about how Address Parsing is handled and used in CiviCRM, refer to the Installation chapter of the Configuration section of this manual. When adding or editing contacts, you will enter and edit such address elements as street number, street name, and Apt/Unit/Suite number according to these standards.
When preparing your data import it is helpful to know what fields are required for Import. You'll want to be sure that these fields are included in your CSV import file. Below is a list of the required fields. The Contact ID field is used to cross reference and attach the activity to the contact so it must match the contact ID of the contact in the system exactly.
The import tool for Activities is similar to that of contacts, but there are some pre-requisites which must be met before running the import. Firstly, Activities cannot be imported unless the contacts and Activity Types already exist in the database. If you need to import Activities for contacts that are not yet available, run a contact import first, preferably including a unique external identifier (most often an ID assigned by the database or application you are importing records from).
Remember, CSV files must be less than 2MB in size. If the file size exceeds this, create multiple CSV files and distribute the data between them.
You can insert new contributions or update existing ones.
If you insert new contributions, your CSV file must include at least the following fields:
If you want to update existing contributions, your CSV file must include at least the following fields:
You can use also use update existing contributions to import new or change existing data in other core or custom contribution fields. When doing this you will still need to include an ID to match to an existing contribution and the Financial Type and Total Amount fields in you CSV file, even if the values you import for those fields are no different from the values already in your database.
You can insert new memberships or update existing memberships.
If you insert new memberships your CSV file must include at least the following fields:
If you want to update existing memberships your CSV file must include at least the following fields:
You can use also use update existing memberships to import new or change existing data in other core or custom membership fields. When doing this you will still need to include Membership ID to match to an existing membership, and the Membership Type and Membership Start Date fields in you CSV file, even if the values you import for those fields are no different from the values already in your database.
In each import session you can either insert new registrations or update existing participant records.
If you insert new registrationsyou need to decide whether to restrict registrations for each event to just one per person (set On duplicate entries to Skip) or to allow duplicate registrations for the same event from a given contact (set On duplicate entries to No Duplicate Checking). In either case your CSV file must include at least the following fields:
If you want to update existing registrations, you should set On duplicate entries to Update. Your CSV file must include at least the following fields:
You can use also use update existing registrations to import new or change existing data in custom participant fields. When doing this you will still need to include Participant ID to match to an existing registration, and the Event ID or Event Title and Participant Status fields in you CSV file, even if the values you import for those fields are no different from the values already in your database.
There is currently no inbuilt way of importing tags or tag sets. You can use this advanced extension though.
If you want to assign individual tags during your contacts import, you will have to either: