Skip to content

Rename columns filter

David Megginson edited this page Sep 1, 2015 · 2 revisions

TODO: update to include Python and the HXL Proxy as well.

The hxlrename command-line tool create a copy of a HXL dataset with one or more of the columns renamed with different tags:

hxlrename --rename x_recipients:beneficiaries_num \
  <dataset-in >dataset-out

Usage

usage: hxlrename [-h] [-r #?<original_tag>:<Text header>?#?<new_tag>]
                 [infile] [outfile]

Rename and retag columns in a HXL dataset

positional arguments:
  infile                HXL file to read (if omitted, use standard input).
  outfile               HXL file to write (if omitted, use standard output).

optional arguments:
  -h, --help            show this help message and exit
  -r #?<original_tag>:<Text header>?#?<new_tag>, --rename #?<original_tag>:<Text header>?#?<new_tag>
                        Rename an old tag to a new one (with an optional new
                        text header).

Examples

Use hxlcount (command) to produce a report on the number of activities for an organisation in each administrative-level-one region, then change the output tag #x_count_num to #x_activities_num:

hxlcount --tags org,adm1 <dataset-in.csv | \
  hxlrename --rename x_count_num:x_activities_num \
  >dataset-out.csv

You can optionally include a text header to show above the renamed tag:

hxlcount --tags org,adm1 <dataset-in.csv | \
  hxlrename --rename "x_count_num:Activity count#x_activities_num" \
  >dataset-out.csv