unravel.tabular.edit_columns module#

Use tabular_edit_columns (edit_cols) from UNRAVEL to drop, keep, rename, or reorder columns in a CSV or XLSX file.

Usage:#

tabular_edit_columns -i ‘path/to/data/*.csv’ [-d col1 col2 … or -c col2 col1 …] [–rename OLD=NEW …] [-o output_dir/] [-v]

unravel.tabular.edit_columns.parse_args()[source]#
unravel.tabular.edit_columns.edit_columns(input_pattern, drop_cols, cols, rename=None, replace=None, output=None, inplace=False, verbose=False)[source]#

Load CSV/XLSX file(s), process columns, and save modified file(s).

Supports:
  • drop columns with -d

  • keep/reorder columns with -c

  • rename columns with -r

  • overwrite inputs with –inplace/-I

  • write to output file/dir with -o

Parameters:#

input_patternstr

File path or glob pattern for input CSV/XLSX files.

drop_colslist or None

List of column names to drop.

colslist or None

List of column names to keep and reorder (all others will be dropped).

renamelist or None

List of strings in the format OLD=NEW to rename columns.

outputstr or None

Path to the output file or directory.

replacelist or None

List of strings in the format OLD=NEW to replace text in column names.

inplacebool

If True, overwrites the input file(s) instead of creating new output files.

verbosebool

If True, prints additional information during processing.

unravel.tabular.edit_columns.main()[source]#