Stored Transformation
Stored transformation detail
Inspect version history, edit inputs, and save a new version without overwriting prior records.
def v($k): .[$k].value // null; def parsed_address: (v("address") // "") as $a | try (($a | capture("^(?<streetAddress>.*?)[.,]\\s*(?<postalCode>\\d{5})\\s+(?<locality>[^.]+)")) as $m | {streetAddress: ($m.streetAddress | gsub("\\s+$"; "")), postalCode: $m.postalCode, locality: ($m.locality | gsub("\\s+$"; "") | gsub("\\.$"; "")), province: (if ($m.postalCode | startswith("28")) then "Madrid" else null end), autonomousCommunity: (if ($m.postalCode | startswith("28")) then "Comunidad de Madrid" else null end)} | with_entries(select(.value != null))) catch {address: $a}; {id: .id, type: "Hotel", name: v("name")} + (if v("description") != null then {hasDescription: {shortDescription: v("description")}} else {} end) + (if v("address") != null then {hasLocation: parsed_address} else {} end)
{
"hasDescription": {
"shortDescription": "Aparthotel TH Las Rozas"
},
"hasLocation": {
"autonomousCommunity": "Comunidad de Madrid",
"locality": "Las Rozas",
"postalCode": "28230",
"province": "Madrid",
"streetAddress": "Camino Viejo de Madrid, 38"
},
"id": "building:hoteles.ayto-xlsx.141",
"name": "Aparthotel TH Las Rozas",
"type": "Hotel"
}