Web API: Importfile: Difference between revisions

From QPR ProcessAnalyzer Wiki
Jump to navigation Jump to search
(Created page with "The '''importfile''' operation imports data from a file to QPR ProcessAnalyzer datatables. HTTP request header '''Authorization''' with value '''Bearer <access token>''' need...")
 
No edit summary
 
(23 intermediate revisions by the same user not shown)
Line 1: Line 1:
The '''importfile''' operation imports data from a file to QPR ProcessAnalyzer datatables.
The '''importfile''' operation imports data from a text file to a [[QPR_ProcessAnalyzer_Project_Workspace#Datatables|datatable]]. The import can be done to an existing or to a new datatable that is created during the import. For an existing datatable, imported data can be appended to the existing data or the existing data can be overwritten.
 
UTF-8 is the only supported character encoding for the imported file. In case any other character encoding is used, characters in the imported file may be interpreted incorrectly.


HTTP request header '''Authorization''' with value '''Bearer <access token>''' needs to be in place to identify the session.  
HTTP request header '''Authorization''' with value '''Bearer <access token>''' needs to be in place to identify the session.  


<pre>
<pre>
Url: POST /api/importfile?param1=value1&param2=value2&param3=value3
Url: POST qprpa/api/importfile?parameter1=value1&parameter2=value2
Content-Type: multipart/form-data
Content-Type: multipart/form-data
Body: file contents
Body: <file contents>
</pre>
</pre>


Following parameters can be defined:
Following query parameters can be defined:
* '''fileType''' (string): Defines the format of the imported file. Options are csv, pacm and xes.
* '''fileType''' (string): Defines the imported file format. Options are '''csv''' (comma-separated values), '''pacm''' (QPR ProcessAnalyzer model format) and '''xes''' (see https://www.tf-pm.org/resources/xes-standard/about-xes). If not specified, the csv is assumed.
* '''importMode''' (string): Defines what kind of data is imported. Options are datatable, events and cases. Used when FileType=csv
* '''projectId''' (integer): When creating a new datatable, defines project id where the datatable is created.
* '''projectId''' (string): Project id. Used when creating a new model or new data table.
* '''objectId''' (integer): When importing data to an existing datatable, defines the target datatable id.
* '''newObjectName''' (string): Model or datatable name. Used when creating a new model or new datatable.
* '''newObjectName''': When creating a new datatable, defines the datatable name.
* '''objectId''' (integer): Model or datatable id. Used when importing data to an existing model or datatable.
* '''append''' (boolean): When ''true'', existing data in the destination datatable is preserved. When ''false'', existing data is removed and also datatable columns are deleted.
* '''csvDelimiter''' (string): Delimiter character for CSV format.
* '''matchByColumns''': JSON array of datatable columns that are used to match the imported rows as follows: If a matching row is found, that existing row is updated (with columns not listed by this setting). In other case, a new row is created to the datatable. By default, no matching columns are defined, so all data is imported as new rows.
* '''csvQualifier''' (string): Character used to enclose strings.
* '''csvDelimiter''' (string): Column delimiter character for the csv format.
* '''csvTimeFormat''' (string): The date format to use when interpreting date values.
* '''csvTimeFormat''' (string): Date format to use when interpreting date values for the csv format.
* '''csvStartImportFromLine''':  
* '''csvQualifier''' (string): Character used to enclose strings for the csv format.
* '''append''' (boolean): When true, the possible previous data is preserved. When importing to datatable with append=0, columns are reset.
* '''csvStartImportFromLine''' (integer): The column name row in the csv file.
* '''isCompressed''' (boolean): When true, input stream is zipped (gzip). Always true if FileType=pacm.
* '''isCompressed''' (boolean): When ''true'', the file is compressed using the gzip format. Only the csv and xes files can be provided as compressed (pacm file is already a gzip file).
 
When importing to an existing datatable, data needs to be converted into each column's datatype. Conversions are made for each datatype as follows:
* String: No conversion needed.
* Integer: Convert digits to corresponding to integer.
* Float: Convert to float using period (.) as the decimal separator.
* DateTime: Convert to date using the provided ''csvTimeFormat''.
* Boolean: Convert to boolean with ''true'' as true value and ''false'' as false value.
* Duration: Convert to integer and interpret the value as ticks (10000 ticks is 1 millisecond).
* Empty data is imported as ''null'' values (applies for all datatypes).
 
If conversion is not possible, an error is returned and the import stops. Note that some of the data may have been imported successfully to the datatable.
 
[[Category: QPR ProcessAnalyzer]]

Latest revision as of 23:03, 7 May 2025

The importfile operation imports data from a text file to a datatable. The import can be done to an existing or to a new datatable that is created during the import. For an existing datatable, imported data can be appended to the existing data or the existing data can be overwritten.

UTF-8 is the only supported character encoding for the imported file. In case any other character encoding is used, characters in the imported file may be interpreted incorrectly.

HTTP request header Authorization with value Bearer <access token> needs to be in place to identify the session.

Url: POST qprpa/api/importfile?parameter1=value1&parameter2=value2
Content-Type: multipart/form-data
Body: <file contents>

Following query parameters can be defined:

  • fileType (string): Defines the imported file format. Options are csv (comma-separated values), pacm (QPR ProcessAnalyzer model format) and xes (see https://www.tf-pm.org/resources/xes-standard/about-xes). If not specified, the csv is assumed.
  • projectId (integer): When creating a new datatable, defines project id where the datatable is created.
  • objectId (integer): When importing data to an existing datatable, defines the target datatable id.
  • newObjectName: When creating a new datatable, defines the datatable name.
  • append (boolean): When true, existing data in the destination datatable is preserved. When false, existing data is removed and also datatable columns are deleted.
  • matchByColumns: JSON array of datatable columns that are used to match the imported rows as follows: If a matching row is found, that existing row is updated (with columns not listed by this setting). In other case, a new row is created to the datatable. By default, no matching columns are defined, so all data is imported as new rows.
  • csvDelimiter (string): Column delimiter character for the csv format.
  • csvTimeFormat (string): Date format to use when interpreting date values for the csv format.
  • csvQualifier (string): Character used to enclose strings for the csv format.
  • csvStartImportFromLine (integer): The column name row in the csv file.
  • isCompressed (boolean): When true, the file is compressed using the gzip format. Only the csv and xes files can be provided as compressed (pacm file is already a gzip file).

When importing to an existing datatable, data needs to be converted into each column's datatype. Conversions are made for each datatype as follows:

  • String: No conversion needed.
  • Integer: Convert digits to corresponding to integer.
  • Float: Convert to float using period (.) as the decimal separator.
  • DateTime: Convert to date using the provided csvTimeFormat.
  • Boolean: Convert to boolean with true as true value and false as false value.
  • Duration: Convert to integer and interpret the value as ticks (10000 ticks is 1 millisecond).
  • Empty data is imported as null values (applies for all datatypes).

If conversion is not possible, an error is returned and the import stops. Note that some of the data may have been imported successfully to the datatable.