Views: 3907
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

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

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

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.

  User export from the system

You can use a user export file from an active site as a template. Execute the following actions:

  1. Go to the User list page (Settings > Manage users > User list).
  2. Click Excel button to download data from the list.
  3. Next, adapt the file to the CSV file requirements. Specifically:
    • delete summary list at the end of table;
    • replace value names in the header for correct Latin names according to Data type table, listed in the subsection Preparing a CSV File;
    • check field content for correct data input according to the Data type table (gender values must be indicated as M and F).
  4.   Import procedure

    In the Import users form, select CSV file as a data source and click Next.

    Fill in the fields in the next tab (Import Settings):

    • Data File – specify the pathname of the CSV file.
    • Field Separator – specify the separator character used in the file.
    • Add Users to Groups – select the group (or groups using Ctrl key) to which to add the user profiles.
    • Path to Images Relative to Site Root – the path to an image file folder relative to which the values of PERSONAL_PHOTO and WORK_LOGO are expected in the file. If the fields is empty, indicate full path relative to site root in the values PERSONAL_PHOTO and WORK_LOGO.
    • Bind Users to Information Block Sections – select an information block to which users having the IBLOCK_SECTION_NAME_* property will be added. Only a single information block can be indicated. In case the same user must be bound to various iblocks, the binding subsequently must be performed manually.
    • Allow LDAP authorization – specify the LDAP authorization server name. You can create a server now by clicking Create if required.
    • Notify User If E-Mail Is Available - notify users about registration at the site via selected template. Works, if user e-mail was indicated inside CSV file.
    • Ignore Duplicate Logins - indicate this option to avoid adding users with logins already in the system during the import.

    Click Next. The next step automatically imports users. Upon completion, a message indicating the number of imported users will be shown.

    Viewing Imported Data

    To view the imported data, open Settings > Manage users > User list showing all the users registered in the system.

    If the import procedure failed for some reason, delete all the records that have succeeded to import, correct the CSV file and perform the above actions again.

    0


    Courses developed by Bitrix24