Data-flo
Data-floSource CodeCGPS
  • INTRODUCTION
    • What is Data-flo
    • Getting Started - Sign In
    • Privacy and Terms Of Service
    • Contact - Help & reporting errors
    • Change log
  • USING DATA-FLO
    • Data-flo site navigation
      • Transformations Page
      • Run Page
      • Canvas
    • Data
      • Bringing data in to Data-flo
      • Getting data out of Data-flo
      • Data Types
        • Boolean
        • Datatable
        • File
        • Graph
        • List
        • Map
        • Number
        • Text
    • Regular Expressions (RegEx)
    • Adaptors overview
      • Components of an adaptor
      • Binding types
        • Bind to Data-flo input
        • Bind to value
        • Bind to another transformation
    • Specific adaptors
      • add-column
      • append-to-list
      • calculate-time-difference
      • change-column-case
      • columns-concatenation
      • concatenate-text
      • create-microreact-project
      • csv-file-to-datatable
      • csv-to-datatable
      • datatable-columns
      • datatable-to-csv-file
      • datatable-to-graph
      • datatable-to-list
      • datatable-to-map
      • datatable-to-sqlite-file
      • date-to-text
      • dbf-file
      • dot-to-graph
      • download-file
      • dropbox-file
      • epicollect-project
      • extend-datatable
      • figshare-file
      • file-to-text
      • filter-blank-values
      • filter-columns
      • filter-list
      • filter-rows
      • filter-rows-numerically
      • force-directed-layout
      • format-date-column
      • forward-geocoding
      • ftp-file
      • gather-rows
      • google-drive-file
      • google-spreadsheet
      • graph-to-dot
      • join-datatables
      • list-to-datatable
      • lookup-map-value
      • merge-datatables
      • merge-lists
      • microreact-project
      • mysql-database
      • newick-leaf-labels
      • oracle-database
      • postgress-database
      • prepend-to-list
      • remove-columns
      • remove-duplicate-rows
      • rename-columns
      • replace-blank-values
      • replace-column-values
      • replace-text
      • replace-text-in-list
      • replace-value
      • reverse-geocoding
      • row-column-value
      • s3-file
      • select-columns
      • send-email-message
      • slice-datatable
      • slice-list
      • smb-file
      • sort-datatable
      • sort-list
      • split-column
      • split-datatable-rows
      • split-list
      • split-text
      • spread-rows
      • spreadsheet-file
      • sql-server-database
      • sqlite-database
      • sum-rows
      • text-template
      • text-to-file
      • unique-list-items
      • update-epicollect-entries
      • update-microreact-project
      • update-smb-file
      • upload-file-to-google-drive
      • upload-files-to-google-drive
      • url-builder
      • yaml-to-json
    • Building a data-flo
      • Debugging mode
      • Show detailed errors on Run Page
      • Permissions - Access Control
    • Tips & Tricks
  • TUTORIALS
    • Prep outbreak data for Microreact
    • Common use cases, solved
      • Fixing datatable headers
      • Select, remove, rename, reorder columns
      • Data in separate files
      • There's no single-column unique row ID (primary key)
      • Ensure non-dates stay non-dates
      • Connect directly to a database
      • Access files on a drive
Powered by GitBook
On this page
  • Examples
  • Extend-datatable to set colours
  • Harmonise data values
  • Showing map in JSON format
  • Tips

Was this helpful?

  1. USING DATA-FLO
  2. Data
  3. Data Types

Map

Define key-value pairs

PreviousListNextNumber

Last updated 2 years ago

Was this helpful?

The Map data type represents a collection of key-value pairs. It is a way to associate one piece of information with another, similar to "recode" function in R or SQL. It is like a two-column list.

A key-value pair consists of two related data elements, and it can be used a bit like an “if this, then that” statement (“if this key, then that value”).

Within a map, the Key must be unique, but the Value doesn't need to be unique. The Key is the unique identifier, and the Value is the information associated with the Key. Each Key is only associated with one Value, but the same Value can be assigned to multiple Keys.

Examples

Extend-datatable to set colours

The Extend-datatable adaptor accepts a Map for the values argument. This argument should provide mapping such that for a given value in the `source` column, a corresponding value should appear in the target column.

If you have a spreadsheet containing a two-column set of column, column__colour then you can pull that into Data-flo and use extend-datatable to associate those colours with the rest of your data.

Harmonise data values

Again using Extend-datatable, we can harmonise inconsistent spellings using a data map.

TIP: The map must include all desired key-value pairs. Don't forget to include the map of values that are not changing (e.g. not just "uk | UK" but also "UK | UK".

Showing map in JSON format

Given the following Datatable:

datatable.json
{
  "columns": [
    "city"
  ],
  "rows": [
    { "city": "Manchester" },
    { "city": "London" }
  ]
}

This map would assign a colour to each city:

map.json
[
  [ "Manchester", "red" ],
  [ "London", "blue" ]
]

Resulting in this Datatable:

extended-datatable.json
{
  "columns": [
    "city",
    "colour"
  ],
  "rows": [
    { "city": "Manchester", "colour": "red" },
    { "city": "London", "colour": "blue" }
  ]
}

Tips

TIP: For a map that may need frequent editing or extension, you can create a dictionary/library of the mapped terms in an external file (csv, spreadsheet, etc).

TIP: If mapping based on an existing column (e.g. in Extend-datatable), use datatable-to-list and unique-list-items to identify all the source column values and ensure that you include all necessary key-value pairs.

Extend datatable 'values' argument uses map data type
identify all existing source column values