From 919a18f8263b1273d59af5f737397a054f50d260 Mon Sep 17 00:00:00 2001 From: Paul Trowbridge Date: Wed, 21 Feb 2018 00:41:46 -0500 Subject: [PATCH] add screen to mapping definition --- sample_discovercard/mapping.md | 91 ++++++++++++++++++++++++++++------ 1 file changed, 76 insertions(+), 15 deletions(-) diff --git a/sample_discovercard/mapping.md b/sample_discovercard/mapping.md index 5999f92..3322020 100644 --- a/sample_discovercard/mapping.md +++ b/sample_discovercard/mapping.md @@ -1,3 +1,59 @@ + + +regular expression screen +--------------------------------------------- + +``` + +------------------------+----+ + source | DCARD | \/ | + +-----------------------------+ + +-----------------------------+ + new name |First 20 | + +-----------------------------+ + +-----------------------------+ + function | extract(replace) | \/ | + +------------------------+----+ + + + + (each block is a regex, all blocks are concatenated into an array and linked to mapped ^alues) + + first 20 characters + +----------------------------------+ + + +----------------------------------------------------------------------------------------------------+ + + | +-----------------------------+ | + | | Field Name| Description | \/| expressed as jsonb path "{Description}") | + +-------+ | +-----------------------------+ | + | | +-------------------------+ | + + |label of return ^alue |f20 | | + | +-------------------------+ | + | +-------------------------+ | + | regular expression |.{1,20} | supply test run ^alues | + | +-------------------------+ | + | +-------------------------+ | + | replace wit | | | + | +-------------------------+ | + | +---+ | + | Map Results|Y/N| | + | +---+ | + | +---+ | + | Find All Matches| g | | + | +---+ | + | filter(s) | + | +-------------------------------------------+ | + | +----------------+ +----------------+ | + | |Category | |Restaurantes | | + | +----------------+ +----------------+ | + | +----------------+ +----------------+ | + | |Category | |Services | | + | +----------------+ +----------------+ | + | | + +----------------------------------------------------------------------------------------------------+ + +``` + + map definition ---------------------------------------------------------- @@ -6,7 +62,7 @@ map definition { "key": "{Description}", "map": "y", - "flag": "", + "flag": "g", "field": "f20", "regex": ".{1,20}", "retain": "y" @@ -14,24 +70,29 @@ map definition ], "name": "First 20", "where": [ - { - } + {"Category":"Restaurantes"}, + {"Category":"Services"} ], "function": "extract", "description": "pull first 20 characters from description for mapping" } -assign values to the result of the regex ------------------------------------------------------ -| retval | map | -| ------------------------------- | ----------------------------------------------------------------------------------- | -| {"f20": "BIG LOTS #00453 STOW"} | {"party": "Big Lots", "reason": "Home Supplies"} | -| {"f20": "1794MOTHERHOOD #1794"} | {"party": "Motherhood", "reason": "Clothes"} | -| {"f20": "3 PALMS HUDSON OH"} | {"city": "Hudson", "party": "3 Palms", "reason": "Restaurante", "province": "Ohio"} | -| {"f20": "36241 7-ELEVEN STOW "} | {"city": "Stow", "party": "7-Eleven", "reason": "Gasoline", "province": "Ohio"} | -| {"f20": "7-ELEVEN 36241 STOW "} | {"city": "Stow", "party": "7-Eleven", "reason": "Gasoline", "province": "Ohio"} | -| {"f20": "98626 - 200 PUBLIC S"} | {"party": "Public Square Parking Garage", "reason": "Recreation"} | -| {"f20": "ACE HARDWARE HUDSON "} | {"party": "Ace Hardware", "reason": "Home Maintenance"} | -| {"f20": "ACH CAFE AND STARBUC"} | {"party": "Starbucks", "reason": "Restaurante"} | +assign new key/values to the results of the regular expression, and then back to the underlying row it came from +----------------------------------------------------------------------------------------------------------------- + +``` ++---------------------------------+------------------+---------------+---------------+-----------------+----------------+ +| returned from expression | party | reason | city | provice | | ++-----------------------------------------------------------------------------------------------------------------------+ +| {"f20": "BIG LOTS #00453 STOW"} | Big Lots |Home Supplies |Stow |Ohio | | +| {"f20": "1794MOTHERHOOD #1794"} | Motherhood |Clothes | | | | +| {"f20": "3 PALMS HUDSON OH"} | 3 Palms |Restaurantes |Hudson |Ohio | | +| {"f20": "36241 7-ELEVEN STOW "} | 7-Ele^en |Gasoline |Stow |Ohio | | +| {"f20": "7-ELEVEN 36241 STOW "} | 7-Eleven |Gasoline |Stow |Ohio | | +| {"f20": "98626 - 200 PUBLIC S"} | Public Sq Parking|Recreation | | | | +| {"f20": "ACE HARDWARE HUDSON "} | Ace Hardware |Home Maint |Hudson |Ohio | | +| {"f20": "ACH CAFE AND STARBUC"} | Starbucks |Restaurantes | | | | ++---------------------------------+----------------------------------+---------------+-----------------+----------------+ +``` \ No newline at end of file