I have done many inline loads before, but I was not aware of the delimiter option until recently so I thought I would share what I learned in my blog today. When loading data that is typed in the script or added manually via the Data Manager, an inline load is used. Below is an example - it is a simple load script that includes the Inline keyword as well as square brackets to load data directly from the script versus a file or external data source.
Looking at the data in the square brackets, the first line indicates the fields that will be loaded – in this case Name and Age. Each line after that and before the ending square bracket, is a new row of data. Each row is on its own line in the script. This example will load four rows of data with two fields: Name and Age.
By default, the field data is separated by commas in the load script – comma is the default delimiter. I recently ran into an issue where the data I needed to load via the inline load script included commas. For example, assume that Name needed to be loaded with the last name first like this:
This script would load the last name in the Name field and the first name in the Age field and the actual ages would not be loaded at all. This is because there are only two fields listed to be loaded Name and Age so the script ignores the second comma and the age because a third field was not defined (on the line after the open square bracket). There are a few ways to handle this as seen below: 1) “delimiter is” can be used to define a delimiter other than the default comma; 2) double quotes and 3) single quotes. My preference is to use the “delimiter is” option and to use a delimiter that is not part of the data I am loading. All three of these options load the data correctly. If changing the delimiter, be sure to change it on the row with the column names as well as the rows of data.
Using “delimiter is” with the inline load is not required but is useful in certain situations. The delimiter can be any character such as a comma, semi-colon or pipe. The key is to use a character that is not found in the data that is being loaded. Inline can be used to load data as seen in this blog but is can also be added to the script manually via Qlik Sense Data Manager. To learn more about using the Data Manager to load data manually, read my blog titled Manual Entry – Adding data manually in Qlik Sense.