How to import data from a csv file

Buzzy supports importing data from a CSV file using the CSV Import option inside the Data Source feature of the micro-app. Access the properties of the microapp on which the data is to be stored, then Simply navigate to the advanced section and click on the Data Source tab selecting the CSV import toggle, then choose a .csv file to be imported by clicking on the “Upload CSV” button and selecting the file, if the upload is successful the file name will appear in the text box.

Configuration

Default Configuration

The CSV Import feature-set can import files with either a default configuration or a custom configuration. For the default configuration simply input an empty JSON object (as seen below).

Custom Configuration

the bare minimum required to get the JSON object working are,

  1. source Object: the source Object contains an array called “transforms” in which the jsonATA transform is contained. As a minimum, the jsonATA must contain the transform “$[].data.$[]” to supply an array of objects which is the format needed as input.

  2. fields array containing objects: a minimum of one object must be specified, a key and type identifier must be provided, the key correlates to the field name and the type identifies what type the field is. If the field is unique to each row, then a unique identifier is added, buzzy will also attempt to guess the unique field if no fields property is provided once the preview button is clicked.

Bare minimum custom input

{
   "source": {
    "description": "Optional Description of Config",
    "type": "csv",
    "transforms": [
      "$[].data.$[]"
    ]
  },
  "fields": [
    {
      "key": "EmployeeName",// Name Of A field unique to each row
      "type": "string",
      "unique": true
    }
  ]
}

Transforms - Example custom input with multiple fields

The transforms property provides a quick and easy way for users to manipulate their data, the transforms property accepts a value of type array with each index containing JsonATA code, then buzzy executes the transforms on each row of data, Note that the final output of the transformed data must be of type array of objects.

Fields

The fields array contains objects identifying what type each field is, for numbers (e.g. 13764852) and Booleans (e.g. true), buzzy will automatically detect the field type. If the value is not of these types, then the value is assumed to be a string.

{
  "fields": [
    {
      "key": "ID",
      "type": "number",
      "unique": true
    },
    {
      "key": "Joined",
      "type": "date"
    },
    {
      "key": "Role", //does not need to be added as its a string
      "type": "string"
    },
    {
      "key": "age", //does not need to be added as its a Number
      "type": "number"
    }
  ]
}

Advanced field types

Support for advanced field types is currently limited to Date and location fields.

Location

The location field takes an object as input. The object has a “type” attribute and “coordinates” attribute.

“Type”: “point” example

“Type”: “MultiPolygon” example

Sample Location Field Import.

The bellow format allows for points to be displayed on a map whilst also having their information in text form displayed as part of the form data, although with the method below, the longitude and latitude must match the address.

{
  "source": {
    "transforms": [
      "$[].data.{'Department_Name': Department_Name , 'geometry': {'type': 'Point','coordinates': [Longitude,Latitude] ,'address': {'formattedAddress': Address, 'country': 'USA','geometry': {'type': 'Point','coordinates': [Longitude,Latitude]} }} }"
    ]
  },
  "fields": [
    {
      "key": "'Department_Name'",
      "type": "string",
      "unique": true
    },
    {
      "key": "geometry",
      "type": "GeoJSON"
    }
  ]
}