Views: 2548
Last Modified: 22.10.2021
|
Importing from a CSV File |
The dedicated User import (Settings > Manage Users > User import) admin section allows importing complete user lists.
Important!
CSV file
It's recommended to create CSV files using MS Excel software. It's advised to check the file encoding by opening it using MS Excel when you have created the file using other software.
in the site encoding. Encoding can be viewed in the site creation/editing form (Settings > System settings > Sites > Sites).
Important! If the system uses the UTF-8 encoding, a CSV file must be created in this encoding as well.
Preparing a CSV File
A valid CSV file must exist before you import users from it. The file must have the following format:
header
data
data
data
Each line in the file represents a table row. A header can include any records in a single line. The header describes the data that follows it. The values in each line (the header and the data) are separated by a delimiter.
Example of user data header
|
LAST_NAME;PERSONAL_PHOTO;NAME;SECOND_NAME;WORK_POSITION;EMAIL;PERSONAL_BIRTHDAY;PERSONAL_GENDER;WORK_PHONE;UF_1C_PHONE_INNER;PERSONAL_MOBILE;PERSONAL_ICQ;LOGIN;IBLOCK_SECTION_NAME_1;IBLOCK_SECTION_NAME_2;IBLOCK_SECTION_NAME_3;IBLOCK_SECTION_NAME_4
|
The data in fields must match the format prescribed by the header. Independently of data existing for corresponding field, the field must be specified.
For example, if the file header has the following format:
LAST_NAME;PERSONAL_PHOTO;NAME;SECOND_NAME;WORK_POSITION;
and there is no data for some fields, say 2, 4 and 5, the data row must still be like the following:
Smith;;John;;;
Fields without data are simple marked by delimiter.
Important! Minimum condition for user import from a CSV file is the specified NAME and LAST_NAME for the user.
Table with field headers and data types
|
The table contains all the data types and a mandatory field attribute.
Value
| Type
| Required | Comments |
ACTIVE | boolean
| No. Default is True. | Active. |
LOGIN | string | No. Auto generated by default. | Specifies a user login, min. 3 characters. |
PASSWORD | string | No. Auto generated by default. | Specifies a user password, min. 6 characters. |
NAME | string | Yes | User’s first name. |
LAST_NAME | string | Yes | User’s last name. |
SECOND_NAME | string | No | User’s second name. |
EMAIL | string | No. Default value is the administrator’s e-mail. | The E-mail address. |
DATE_REGISTER | date | No. Default is the current date. | The date a user was registered. |
LID | string | No | The ID of a default site for notifications. |
ADMIN_NOTES | string | No | Administrator’s notes. |
EXTERNAL_AUTH_ID | string | No | The external authorization source ID. |
XML_ID | string | No | The user ID for external connection (e.g. ID in an external database). |
Personal data | Type | Required | Comments |
PERSONAL_GENDER | string | No | Gender: M – male; F – female. |
PERSONAL_BIRTHDAY | date | No | Date of birth. |
PERSONAL_CITY | string | No | Address: city. |
PERSONAL_STATE | string | No | Address: region, state etc. |
PERSONAL_ZIP | string | No | Address: ZIP code. |
PERSONAL_WWW | string | No | Personal web site URL. |
PERSONAL_PROFESSION | string | No | Profession. |
PERSONAL_NOTES | string | No | Arbitrary notes. |
PERSONAL_ICQ | string | No | ICQ account number. |
PERSONAL_PHONE | string | No | Home phone. |
PERSONAL_PHOTO | string | No | The path to a photo relative to a folder specified in the import parameters. |
PERSONAL_FAX | string | No | Fax number. |
PERSONAL_MOBILE | string | No | Mobile phone number. |
PERSONAL_PAGER | string | No | Pager. |
PERSONAL_STREET | string | No | Address: street. |
PERSONAL_MAILBOX | string | No | Address: P/O box. |
Work data | Type | Required | Comments |
WORK_COMPANY | string | No | Company name. |
WORK_DEPARTMENT | string | No | Department. |
WORK_POSITION | string | No | Position. |
WORK_WWW | string | No | Company web site URL. |
WORK_PHONE | string | No | Work phone. |
WORK_FAX | string | No | Work fax number. |
WORK_PAGER | string | No | Pager. |
WORK_STREET | string | No | Company address: street. |
WORK_MAILBOX | string | No | Company address: P/O box. |
WORK_CITY | string | No | Company address: city. |
WORK_STATE | string | No | Company address: region, state etc. |
WORK_ZIP | string | No | Company address: ZIP code. |
WORK_PROFILE | string | No | Company profile. |
WORK_LOGO | string | No | The path to a company logo image relative to a folder specified in the import parameters. |
WORK_NOTES | string | No | Arbitrary notes. |
UF_* | string | No | User field. |
IBLOCK_SECTION_NAME_* | string | No | Information block binding. |
|
|
Please be advised the following aspects before formatting CSV file:
- Delimiter can be as follows: comma (,), semicolon (;), space or tabulation. Spaces between values are prohibited. When space character is used as a delimiter, ensure that there are no double spaces between values.
- When comma is a part of a value (for example: object properties are comma-separated), enclose the value in double quotation marks
"orange,red,green"
.
- When double quotation marks are part of the value, enclose the value into the pair of double quotation marks. For example, "John" in CSV file must have the following format:
""John""
.
- Empty strings in CSV file are prohibited.
- Headers, string values and login are case-insensitive.
- Passwords are case-sensitive.
- Logical values have the following format: Y — true; N — false.
- Data, located in the string after the last identified value in the header string is ignored. For example, if file header string indicates 10 characters and the data string contains 12 characters, the last 2 will be removed.
- Data elements which values are not specified are processed as empty strings.
- Time format must be set in the site language format. For example:
MM/DD/YYYY HH:MI:SS
(for English).
CSV file example
|
LAST_NAME,NAME,LOGIN,PASSWORD,EMAIL
Silver,John,jsilver,Password1,jsilver@company.com
Smith,Andrew,asmith,Password2,asmith@company.com
Siskin,Peter,psiskin,Password3,psiskin@company.com
Oldfield,Ben,boldfield,Password4,boldfield@company.com
Baddeley,Jane,jbaddeley,Password5,jbaddeley@company.com
Bloodsworth,Helen,hbloodsworth,81QE1RO98M,hbloodsworth@company.com
Coleman,Kate,kcoleman,D0O4IAYOX0,kcoleman@company.com
Gabbard,Michael,mgabbard,CDUEND3SMX,mgabbard@company.com
Laycock,Harry,hlaycock,GCH425XAM6,hlaycock@company.com
Stockdale,Hamilton,hstockdale,ZD3PZHP2E7,hstockdale@company.com
|
To make sure you will not encounter any errors during import, check that the file data meet the specification described at the beginning of this chapter. You can check this by opening a CSV file in MS Excel:
- Check the headers.
- Ensure the length of all passwords is at least 6 symbols.
- Ensure the length of all logins is at least 3 symbols.
You can start import after checking CSV file.
You can use a user export file from an active site as a template. Execute the following actions: