Breadcrumbs

Data Manipulation - Map Column Names

Overview

This Allie workflows template allows the user to map columns from the set [Column A, Column B, Column C …] to [Column A*, Column B*, Column C*, …] in a .csv file.


Name

Reference

Type

Required

Description

Source File Path

DM_SOURCE_FILE_PATH

Alphanumeric

Yes

Path to the file that will be remapped

Source Folder Path

DM_SOURCE_FOLDER_PATH

Alphanumeric

No

Folder in workflows that the source file path is located in

Mapping File

DM_MAPPING_FILE

File Upload

Yes

Mapping File that will be used to change the column names.







What the script does

  1. Read input file

    1. Uses the folder path and file path to build a path to the csv located in workflows that will be renamed

  2. Find exact column matches between source file.

    1. The Mapping file should be formatted as followed (You do not need the column headers used in this example, this is just to show the relationship in the mapping)

    2. The mapping is not case sensitive, and will ignore any columns that don’t exist in the original source file, so be sure that things are spelled correctly otherwise it will get skipped.

Old Names (Source File Path Column Headers)

New Names


ID

Identification


First-Name

first_name


This does not exist in the original file

This won’t cause an error


Last_Name

anything you want


  1. Overwrite the source file path with the updated column names


Tips

You can use a bash template before and after the Map Column Names template with the code

cat my_csv.csv

to print out the csv if you wish to check that the renaming was successful