Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I need to create a CSV, Excel, or QVD table in Qlik Cloud with an automation, without using third-party blocks.
This file should be able to update by adding new records each time the automation runs.
I have the data stored in a variable, and I was trying to use the "Create Datafile in Space" block by converting my variable into Base64, but the file it creates is not readable.
There's some nuance in the way you handle linebreaks, since automate does strip some out if you're building it on the fly. Here's an example that works (copy and paste this into a workspace):
{"blocks":[{"id":"AF5968A2-ABD8-43B7-B941-42E8CE2ED91D","type":"StartBlock","disabled":false,"name":"Start","displayName":"Start","comment":"","childId":"CF55930D-2B6B-4EE3-9340-7564CB4BD6CC","inputs":[{"id":"run_mode","value":"manual","type":"select","structure":{}}],"settings":[],"collapsed":[{"name":"loop","isCollapsed":false}],"x":0,"y":0},{"id":"9BD7D021-2346-40A9-A466-2185111DCF3D","type":"SnippetBlock","disabled":false,"name":"CreateDataFileInSpace","displayName":"Qlik Cloud Services - Create Data File In Space","comment":"","childId":null,"inputs":[{"id":"61682ab0-518e-11f0-9fd0-e399ee9be2fa","value":"641c3694840b319aec80a78a","type":"string","displayValue":"data file testing (641c3694840b319aec80a78a)","structure":{}},{"id":"616a41d0-518e-11f0-8fad-e5ba80339beb","value":"hello-world.csv","type":"string","structure":{}},{"id":"616c0350-518e-11f0-b180-d1b0bc5147c3","value":"csv-utf8","type":"select","displayValue":"csv-utf8","structure":{}},{"id":"616db980-518e-11f0-b5b5-474371f72f8c","value":"{ base64encode: { implode: { $.myrows }, ',' } }","type":"string","structure":{}},{"id":"616f69b0-518e-11f0-8713-59102435b4ae","value":null,"type":"string","structure":{}}],"settings":[{"id":"blendr_on_error","value":"stop","type":"select","structure":{}},{"id":"automations_censor_data","value":false,"type":"checkbox","structure":{}}],"collapsed":[{"name":"loop","isCollapsed":false}],"x":0,"y":240,"datasourcetype_guid":"61a87510-c7a3-11ea-95da-0fb0c241e75c","snippet_guid":"61491820-518e-11f0-8d36-0772c7c04565"},{"id":"CF55930D-2B6B-4EE3-9340-7564CB4BD6CC","type":"VariableBlock","disabled":false,"name":"myrows","displayName":"Variable - myrows","comment":"","childId":"9BD7D021-2346-40A9-A466-2185111DCF3D","inputs":[],"settings":[],"collapsed":[{"name":"loop","isCollapsed":false}],"x":0,"y":120,"variableGuid":"FADE41B1-7084-4DF0-A16F-3AAC6E79E883","operations":[{"key":"8E81347C-6E85-4250-BEE3-CC15521E8197","id":"add_item","name":"Add item to { variable }","value":"field1,field2"},{"key":"9018A4B8-7C22-4E14-83C8-68CF540E8E86","id":"add_item","name":"Add item to { variable }","value":"{ linebreak }row1data1,row1data2"},{"key":"DE1819CA-3650-4C46-B1FB-5887D1C31D55","id":"add_item","name":"Add item to { variable }","value":"{ linebreak }row2data1,row2data2"}]}],"variables":[{"guid":"F9EDBDE3-74D8-4DBB-BFDE-44B9EA65C202","name":"mydata","type":"string"},{"guid":"FADE41B1-7084-4DF0-A16F-3AAC6E79E883","name":"myrows","type":"list"}]}
Which looks like the attached screenshots.View of data in the data viewer in hub
The automation
The data payload
Conversion of the data payload
I managed to create a readable CSV file using a Python block that generates a base64 file from a JSON. Then I export it to CSV using the 'Create data file in space' block. Does anyone know if I can overwrite this Excel file?
Could you try with the full mime type example provided in the input description?
text/csv; charset=utf-8
Currently, it uses that option. the file is created but the resulting file it is unreadable.
There's some nuance in the way you handle linebreaks, since automate does strip some out if you're building it on the fly. Here's an example that works (copy and paste this into a workspace):
{"blocks":[{"id":"AF5968A2-ABD8-43B7-B941-42E8CE2ED91D","type":"StartBlock","disabled":false,"name":"Start","displayName":"Start","comment":"","childId":"CF55930D-2B6B-4EE3-9340-7564CB4BD6CC","inputs":[{"id":"run_mode","value":"manual","type":"select","structure":{}}],"settings":[],"collapsed":[{"name":"loop","isCollapsed":false}],"x":0,"y":0},{"id":"9BD7D021-2346-40A9-A466-2185111DCF3D","type":"SnippetBlock","disabled":false,"name":"CreateDataFileInSpace","displayName":"Qlik Cloud Services - Create Data File In Space","comment":"","childId":null,"inputs":[{"id":"61682ab0-518e-11f0-9fd0-e399ee9be2fa","value":"641c3694840b319aec80a78a","type":"string","displayValue":"data file testing (641c3694840b319aec80a78a)","structure":{}},{"id":"616a41d0-518e-11f0-8fad-e5ba80339beb","value":"hello-world.csv","type":"string","structure":{}},{"id":"616c0350-518e-11f0-b180-d1b0bc5147c3","value":"csv-utf8","type":"select","displayValue":"csv-utf8","structure":{}},{"id":"616db980-518e-11f0-b5b5-474371f72f8c","value":"{ base64encode: { implode: { $.myrows }, ',' } }","type":"string","structure":{}},{"id":"616f69b0-518e-11f0-8713-59102435b4ae","value":null,"type":"string","structure":{}}],"settings":[{"id":"blendr_on_error","value":"stop","type":"select","structure":{}},{"id":"automations_censor_data","value":false,"type":"checkbox","structure":{}}],"collapsed":[{"name":"loop","isCollapsed":false}],"x":0,"y":240,"datasourcetype_guid":"61a87510-c7a3-11ea-95da-0fb0c241e75c","snippet_guid":"61491820-518e-11f0-8d36-0772c7c04565"},{"id":"CF55930D-2B6B-4EE3-9340-7564CB4BD6CC","type":"VariableBlock","disabled":false,"name":"myrows","displayName":"Variable - myrows","comment":"","childId":"9BD7D021-2346-40A9-A466-2185111DCF3D","inputs":[],"settings":[],"collapsed":[{"name":"loop","isCollapsed":false}],"x":0,"y":120,"variableGuid":"FADE41B1-7084-4DF0-A16F-3AAC6E79E883","operations":[{"key":"8E81347C-6E85-4250-BEE3-CC15521E8197","id":"add_item","name":"Add item to { variable }","value":"field1,field2"},{"key":"9018A4B8-7C22-4E14-83C8-68CF540E8E86","id":"add_item","name":"Add item to { variable }","value":"{ linebreak }row1data1,row1data2"},{"key":"DE1819CA-3650-4C46-B1FB-5887D1C31D55","id":"add_item","name":"Add item to { variable }","value":"{ linebreak }row2data1,row2data2"}]}],"variables":[{"guid":"F9EDBDE3-74D8-4DBB-BFDE-44B9EA65C202","name":"mydata","type":"string"},{"guid":"FADE41B1-7084-4DF0-A16F-3AAC6E79E883","name":"myrows","type":"list"}]}
Which looks like the attached screenshots.View of data in the data viewer in hub
The automation
The data payload
Conversion of the data payload
I managed to create a readable CSV file using a Python block that generates a base64 file from a JSON. Then I export it to CSV using the 'Create data file in space' block. Does anyone know if I can overwrite this Excel file?