Command line import

<< Click to Display Table of Contents >>

Navigation:  Modules > Maintenance and settings > Settings >

Command line import

Go to Maintenance and settings | Settings | Command line import.

 

This screen shows an overview of all TimeWriter aspects and fields that can be used for the import of data, using the command line. Files to be imported must be of a certain format and structure. Field naming must also meet certain conditions. An aspect of field name can only contain letters (without accents), digits or an underscore and cannot start with a digit. Spaces in aspect and field names will/must be replaced with underscores. In the overview all aspect and field names that do not meet these conditions are grayed out and marked with a exclamation point.

 

Import files can be provided in XML or Excel format. Example files can be generated using the buttons "Generate XML" (just one file) and "Generate Excel" (one file per aspect). The example files contain all valid TimeWriter aspects and field names.

 

General structure of XML import files:

XML structure

Explanation

<TwImport>

 <Employee>

   <Record>

     <Id>value</Id>

     <Name>value</Name>

     <Email>value</Email>

     etc...

   </Record>

   <Record>

     etc...

   </Record>

 </Employee>

 <Customer>

    etc...

 </Customer>

</TwImport>

Aspects to be imported can all be in one file. This XML file must start with a tag <TwImport> end end with tag </TwImport>.

An aspect section begins and ends with a tag that contains the aspect name as entered in TimeWriter, for example <Employee> and </Employee>.

An aspect section can contain one or more record sections. These record sections start with a tag <Record> and end with tag </Record>. So, one aspect section contains all aspect records.

A record section contains the start and end tags for fields, for example <Name>...</Name> or <Email>...</Email>. The field names are the same as the field labels as shown on TimeWriter. The field value is placed between the field tags. So, a record section contains all fields to be imported for one aspect.

 

 

General structure of Excel (.xls, .xlsx) import files:

Excel structure

Explanation

File 1 / sheet 1:

Employee

Id

Name

Email

etc...

Record

value

value

value

 

Record

etc...

etc...

etc...

 

 

File 2 / sheet 1:

Customer

Id

Name

etc...

etc...

Record

value

value

value

 

Record

etc...

etc...

etc...

 

Only the first sheet of an Excel file can contain the data to be imported.

The first row of the sheet is a header row. The first cell of the header row always contains the aspect name as entered in TimeWriter (for example Employee or Customer). The other cells of the first row contain the field names as shown on the field labels in TimeWriter.

Below the header row are the rows with the field values. The first cell of these rows always contains the indication Record.

 

The files to be imported have to be placed in a folder called "import". This folder is already available in the main TimeWriter folder. TimeWriter will try to import all XML and Excel files found in this folder. After processing an import file, a result file with the same name and an insertion ".result" will be created. This file contains the result of an import (Ok, failed or partly failed) and warnings and errors found. An import can fail, for example, because a file is provided in a wrong format. An import can partly fail because mandatory fields are missing or because certain data is not unique. It is advised to check the result files after every import.

 

As long as a result file is present in the import folder, the corresponding import file will not be processed (again).

 

Adding and/or overwriting records during command line import

During the import aspect data can be added or overwritten in TimeWriter, depending on if the import file contains an ID field and if this ID field contains a value or not:

Description

Action

No ID field available

Add record

The ID field is available but contains no value or a value of zero.

Add record

The ID field is available, contains a value and already exists in TimeWriter

Overwrite record (only the fields provided in the import file will be overwritten)

The ID field  is available, contains a value and does not exist TimeWriter

Add record, using the ID value provided

All of this on condition that the other data to import is valid as well.