Skip to main content
Question

Grouping and Listing fieldnames and values in Pipelines

  • March 2, 2023
  • 0 replies
  • 61 views

Forum|alt.badge.img+6

I'm importing a flat file of workorders into a staging table, then looking to load it into the production tables. 

The file has about 24 columns of parts that could be installed, with a count.  Looks a bit like the below:

DOORBELL CAMERA INDOOR CAMERA OUTDOOR CAMERA TAKEOVER MODULE DOOR/WINDOW SENSOR
1       2
1   1   2

I'm not using this data for inventory .. it's purely informational.

Using pipelines - is there an easy way put all those columns into a single multi-line text block, separated into a list - skipping over the blank ones?  EG -- that first record would like the below or similar:

Doorbell Camera: 1 | Door / Window Sensor: 2

Thanks!



------------------------------
Malcolm McDonald
------------------------------
This topic has been closed for replies.

Forum|alt.badge.img+6
  • Quickbase Staff
  • March 2, 2023

Hi Malcolm, this block will output close to what you want.  You'll need to update the list of fields on line 2, and replace 'c' on lines 3 and 5 with the appropriate step letter in your pipeline:

{# Define the list of fields to use -#}
{% set fields = ['doorbell_camera', 'indoor_camera', 'outdoor_camera', 'takeout_camera', 'door_window_sensor'] -%}
{% for field in fields if c[field]|int > 0  -%}
{# Format/capitalize the field name -#}
{{field.split('_') | map('capitalize')|join(' ') }}: {{c[field]}}{{ ' | ' if not loop.last }}
{%- endfor -%}

Sample output:

Doorbell Camera: 1 | Takeout Camera: 3 | Door Window Sensor: 2

The field names don't have the exact formatting (e.g. no slashes) since that info isn't available on the jinja field name. 

Hope that helps!



------------------------------
Doug Henning
------------------------------