In flespi, we process and store all devices messages in JSON format, while sometimes you need to export a massive array of data to filter out certain values, run custom math operations applied to specific columns, or just analyze the data in a familiar table view. In this article, we’ll show you the options for exporting message parameters as .csv or .json files.
Export messages from the panel
a) On the Device > Logs & Messages tab, click on the ‘three-dots’ icon either in the Logs or Messages pane and select the ‘Export CSV’ option to download a .csv file. Before downloading, you’ll be prompted to convert UNIX timestamps to human-readable dates. Please note, that file will contain all messages within the preselected timeframe, so you can't export just one message or a subset of them.
b) To export a single or multiple messages, select them on the Messages pane, right-click, and choose 'Copy messages'. Parameter values will be copied to the clipboard in a single-line JSON format applicable for input as an object in the API playground.
c) Another option allows you to select an event in the Logs pane, right-click on it, and select 'Copy log object' to copy a corresponding message as JSON.
Export messages via REST API
Alternatively, you can send a REST API request and export the output in CSV or JSON using the API Playground. This method allows you to retrieve messages by selecting multiple devices and defining custom logic, such as filtering out custom parameters. All of this makes it more flexible option compared to a straightforward data export from the panel.
a) Switch to Device > Info > API tab. For example, to get only the last 10 messages received, you can perform this GET request. As the output window pops up, toggle the default JSON view by clicking on the dedicated ‘table’ icon in the bottom-right corner.
The ‘Export CSV’ icon will appear in the top-right corner for quick .csv download.
b) If you need to copy the output in JSON, toggle back to the JSON view by clicking on the ‘{...}’ icon in the bottom-right corner and hit the ‘Copy to clipboard’ icon next to it. This option will provide you with formatted JSON, not a single-lined one.
Hint You can process messages either incoming or stored with a wide set of plugins:
- re-register messages to update data processing done by plugins and calculators,
- erase specific parametersin your message with the msg-erase plugin,
- copy selected messages to another device to duplicate or even merge devices with the msg-copy plugin,
- restore specific parameters from the stored message with the same timestamp with the msg-merge plugin.