Skip to content

Grouping data item parts by regular expressions

If you have data which consists of more than 1 image you can import this data as one data item. It will then consist of those files which are in the following called data item parts. As a default if you use the regular frontend import function you will get a data item which has one data item part called "image". If you want to have more you can import them using the regex import under advanced options on the import page. But they need to be in a format where the relation between the images is distinguishable from the file name.

Quick Start

Define two RegEx groups (?<name>...) matching the data item name (?<part>...) matching the data item part The regular expression is applied to the absolute file path.

Check out this page for more information on regular expressions.

Example 1

Suppose you would like to group the following files by name * file1_depth.jpg * file1_intensity.jpg * file2_depth.jpg * file2_intensity.jpg

Applying the regular expression

(?<name>.+?)_(?<part>depth|intensity)

would group them into two data items * file1: [depth: file1_depth.jpg, intensity: file1_intensity.jpg] * file2: [depth: file2_depth.jpg, intensity: file2_intensity.jpg]

Example 2

Suppose you would like to group the following files by extension * file1.jpg * file1_depth.jpg * file2.jpg * file2_color.jpg

Applying the regular expression

(?<name>.+?)(?:_(?<part>depth|color))?.jpg

would group them into two data items * file1: [undefined: file1.jpg, depth: file1_depth.jpg] * file2: [undefined: file2.jpg, color: file2_color.jpg]

file1_intensity.jpg will result in a new data item if it is not matched by the regex with the data item part "undefined"

Part Mapping

You can optionally provide a JSON mapping to rename the parts matched by the (?...) group. Applying the part mapping

{ "undefined": "image", "depth": "depth_image", "color": "color_image" }

would rename the parts in the data items as follows file1: [image: file1_1.png, depth_image: file1_depth.png] file2: [image: file2_1.png, color_image: file2_2.png]