Bosch IoT Insights

Download query results

Query results can not only be inspected within the user interface, they can also be downloaded to your local computer (for further usage within a specific software or for manual inspection for example). Technically, the download can be triggered two ways: The preferred approach is to set the HTTP Accept header, telling the Bosch IoT Insights backend which MIME type of the response is expected. Another approach is to append the format parameter to the requested URL (both approaches are described below). The user interface furthermore offers the possibility to select predefined CSV formats or to apply custom CSV formats easily, using a selection dialog. Within this dialog, special CSV formats (like the standardized RFC 4180 or Excel-ready formats) can be selected when a CSV download is requested. But the user can also configure own CSV export formats, specifying the output formatting according to one’s needs. The available parameters, as well as their default values and their influence on the output CSV file, are listed below.

Please note that the default format, if no other predefined or custom format is requested, follows the RFC 4180 standard (which is also explained below).


Further information:


Approaches

Approach 1: HTTP accept header

When requesting the MongoDB Query Service (also see here), the Accept header of the request specifies the expected MIME type of the response. When triggering a CSV download, a sample Accept header could therefore look like this:

...
Accept: text/csv
...

Furthermore, predefined formats are also supported, such as:

...
Accept: text/vnd.sfde.uniview+csv
...

As well as the possibility to specify own CSV formats within the Accept header:

...
Accept: text/csv;columnSeparator=tab;decimalSeparator=comma;dateTimeFormat="dd.MM.yyyy HH:mm"
...

Whereas the header for requesting a JSON file download would look like this:

...
Accept: application/json
...

Approach 2: URL format parameter

If the setting of HTTP headers is not possible or appropriate, the requested URL can be extended with the format parameter. Note that the arguments need to be URL encoded, as well as the date time formatting parameter needs to be enclosed with quotation marks. Therefore, a sample URL could look like this:

...
https://bosch-iot-insights.com/mongodb-query-service/v2/queries/{id}/result?format%3Dtext%2Fcsv
...

Or with appended parameters:

...
https://bosch-iot-insights.com/mongodb-query-service/v2/queries/{id}/result?format%3Dtext%2Fcsv%3BdateTimeFormat%3D%22dd.MM.yyyy%20HH%3Amm%22
...

Approach 3: CSV export dialog

As already stated above, the user has the comfortable possibility to specify the CSV download format via a dialog in the UI.

Available download formats

Bosch IoT Insights offers the possibility to set the following MIME types, whereas the standard text/csv MIME type can be appended with parameters (as explained above):

  • text/csv

  • text/vnd.sfde.excel.de+csv

  • text/vnd.sfde.uniview+csv

  • application/json

  • application/zip

CSV formatting parameters

To satisfy different needs and formats, Insights offers eight parameters with which the CSV output can be modified. The following table lists the parameter names, the default values (when only text/csv is set within the header/URL), the possible arguments and the result within the generated CSV:

Parameter name

Default value

Possible arguments

CSV result

charset

[UTF-8]

all available standard Java charsets, e.g.

  • [UTF-16]

  • [UTF-32]

  • [US-ASCII]

  • etc.

file encoding

locale

[en]

  • [en]

  • [de]

  • english date time names

  • german date time names

header

[present]

  • [present]

  • [absent]

  • header as first row

  • first dataset as first row

lineBreak

[CRLF]

  • [CRLF]

  • [LFCR]

  • [LF]

  • [CR]

  • [\r\n]

  • [\n\r]

  • [\n]

  • [\r]

columnSeparator

[comma]

  • [comma]

  • [semicolon]

  • [tab]

  • [,]

  • [;]

  • [\t]

masking

[false]

  • [false]

  • [true]

  • whatever.value.xxx

  • "whatever.value.xxx"

decimalSeparator

[dot]

  • [dot]

  • [comma]

  • [.]

  • [,]

dateTimeFormat

[yyyy-MM-dd HH:mm:ss]

all valid date time formats

formats date time fields

Predefined CSV formats

When no parameters are added to the HTTP Accept header or to the format URL parameter, Insights checks if the MIME type and subtype matches a predefined format. The predefined CSV formats are specified below:

  • RFC 4180

    • MIME type: text/csv

    • charset: UTF-8

    • locale: en

    • header: present

    • lineBreak: CRLF

    • columnSeparator: comma

    • masking: false

    • decimalSeparator: dot

    • dateTimeFormat: yyyy-MM-dd HH:mm:ss

  • Excel DE

    • MIME type: text/vnd.sfde.excel.de+csv

    • charset: UTF-8

    • locale: de

    • header: present

    • lineBreak: CRLF

    • columnSeparator: semicolon

    • masking: false

    • decimalSeparator: comma

    • dateTimeFormat: dd.MM.yyyy HH:mm:ss

  • UniView

    • MIME type: text/vnd.sfde.uniview+csv

    • charset: UTF-8

    • locale: de

    • header: present

    • lineBreak: CRLF

    • columnSeparator: semicolon

    • masking: false

    • decimalSeparator: comma

    • dateTimeFormat: dd.MM.yyyy HH:mm:ss