{
  "meta": {
    "version": "4.000.9103",
    "fileFormatVersion": "0.4",
    "date": "2024-12-02T22:05:14.875Z",
    "name": "csv-array-export-to-file",
    "description": "",
    "tags": [],
    "schedulerLogOff": true
  },
  "data": {
    "datanodes": [
      {
        "name": "csv",
        "type": "CSV_file_reader_plugin",
        "settings": {
          "name": "csv",
          "data_path": "CH4-short.csv",
          "content": "\"lat\",\"lng\",\"CH4\"\r\n48.876684, 2.175765, 1.94\r\n48.876684, 2.175765, 1.95\r\n48.876684, 2.175765, 1.92\r\n48.876705, 2.175806, 1.93\r\n48.876705, 2.175806, 1.99\r\n",
          "delimiter": "",
          "eol": "",
          "quote_char": "\"",
          "head": true,
          "skip_empty_lines": true,
          "dynamic_typing": true,
          "pluck": true,
          "embedding_object": false,
          "nb_meta_lines": 0,
          "nb_subheader_lines": 0
        }
      },
      {
        "name": "download",
        "type": "JSON_formula_plugin",
        "settings": {
          "name": "download",
          "autoStart": false,
          "explicitTrig": true,
          "json_var_formula": "function convertArrayOfObjectsToCSV(args) {  \n\tvar result, ctr, keys, columnDelimiter, lineDelimiter, data;\n\n\tdata = args.data || null;\n\tif (data === null || !data.length) {\n    \treturn null;\n    }\n\n    columnDelimiter = args.columnDelimiter || ';';\n    lineDelimiter = args.lineDelimiter || '\\n';\n\n    keys = Object.keys(data[0]);\n    \n    result = '';\n\n    data.forEach(function(item) {\n        ctr = 0;\n        keys.forEach(function(key) {\n            if (ctr > 0) result += columnDelimiter;\n            result += item[key];\n            ctr++;\n        });\n        result += lineDelimiter;\n    });\n    return result;\n}\n\nfunction downloadCSV() {\n                   \n    var csv = convertArrayOfObjectsToCSV({    \n        data: dataNodes.table        \n    });\n    \n    if (csv === null) return;\n        \n    filename = 'example.csv';\n    \n    if (!csv.match(/^data:text\\/csv/i)) {    \n        csv = 'data:text/csv;charset=utf-8,' + csv;        \n    }\n    \n    data = encodeURI(csv);    \n    link = document.createElement('a');    \n    link.setAttribute('href', data);    \n    link.setAttribute('download', filename);    \n    link.click();\n    \n    return csv;\n}\n\nreturn downloadCSV();\n\n"
        }
      },
      {
        "name": "table",
        "type": "JSON_formula_plugin",
        "settings": {
          "name": "table",
          "json_var_formula": "var t= _.unzip(_.values(dataNodes[\"csv\"]),3);\nt.unshift(_.keys(dataNodes[\"csv\"]));\n\nreturn t;"
        }
      }
    ]
  },
  "libraries": {
    "pyodideStandard": [],
    "pyodideMicropip": []
  },
  "dashboard": {
    "flatUiTableA": {
      "layout": {
        "top": 4,
        "left": 14,
        "height": 433,
        "width": 768,
        "z-index": "3"
      },
      "container": {
        "instanceId": "flatUiTableA",
        "modelJsonId": "flatUiTable"
      },
      "modelParameters": {
        "headerLine": true,
        "indexColumn": false,
        "tableValueFontSize": 0.5,
        "striped": true,
        "valueColor": "var(--widget-table-value-color)",
        "valueFontFamily": "var(--widget-font-family)",
        "valueAlign": "left",
        "bordered": true,
        "noBorder": false,
        "editableCols": "[]",
        "backgroundColor": {
          "primary": "var(--widget-color-0)",
          "secondary": "var(--widget-table-striped-odd)"
        },
        "paginationMinNbr": 10,
        "paginationOptions": "[10, 50, 100, 500]",
        "paginationDefaultValue": 10,
        "showWidget": true,
        "enableWidget": true
      },
      "modelHiddenParams": {
        "value": null
      }
    },
    "flatUiFileInputButtonA": {
      "layout": {
        "top": 462,
        "left": 547,
        "height": 63,
        "width": 233,
        "z-index": "4"
      },
      "container": {
        "instanceId": "flatUiFileInputButtonA",
        "modelJsonId": "flatUiFileInputButton"
      },
      "modelParameters": {
        "text": "Export to CSV file",
        "numberOfTriggers": 1,
        "fileInput": false,
        "binaryFileInput": false,
        "buttonFontSize": 0.3,
        "displayIcon": false,
        "fontAwesomeIcon": "",
        "buttonFontFamily": "var(--widget-font-family)",
        "buttonTextColor": "var(--widget-button-primary-text)",
        "buttonDefaultColor": "var(--widget-button-primary-color)",
        "buttonActiveColor": "var(--widget-button-active-color)",
        "buttonHoverColor": "var(--widget-button-hover-color)",
        "showWidget": true,
        "enableWidget": true
      },
      "modelHiddenParams": {}
    }
  },
  "connections": {
    "flatUiTableA": {
      "value": {
        "name": "value",
        "dataNode": "table",
        "dataFields": []
      }
    },
    "flatUiFileInputButtonA": {
      "trigger1": {
        "name": "trigger1",
        "dataNode": "download",
        "dataFields": []
      }
    }
  },
  "display": {
    "theme": "default",
    "backgroundColor": "var(--widget-color-0)",
    "inheritThemeBackgroundColor": true,
    "marginX": 10,
    "marginY": 10,
    "width": 1294,
    "height": 590,
    "enforceHeightLimit": false
  },
  "navBarNotification": false
}