storage_read

Reads file from DataJet storage.

Accepts:

  • filename - the name of the file stored in DataJet storage

Result is saved in a variable that follows as keyword.

Result has following format:

{
    "ok": true,
    "error": null, // null only when ok: true
    "file": {
        "name": "file.csv",
        "content": "a,b\n1,2", // content of the file as string
    }
}

Code below reads the content of file: file.csv from the storage. If successful, logs content, if failed logs message.

{% storage_read filename: "file.csv" as read_result %}

{% if read_result.ok %}
  {% comment %}Proceed with processing the file. Content saved in file_content{% endcomment %}
  {% log read_result.file.content %}
{% else %}
  {% comment %}Error while reading file from storage{% endcomment %}
  {% log read_result.error %}
{% endif %}

Last updated