Skip to content

perron2/csvm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

csvm

Command line tool to map column names and field values of a CSV file.

Build

With Go installed execute

go build -ldflags="-s -w" -trimpath perron2.ch/csvm

You can also use the associated makefile if you have make and UPX installed on your system. MacOS builds do currently not use UPX to compress the generated executable file due to an unresolved problem in UPX on macOS 13+.

make windows
make linux
make darwin

Examples

Rename two columns and map the possible values of the status column to something else:

csvm -mapfile mappings.txt original.csv mapped.csv

The mapping file mappings.txt being defined as:

id: code
name: title
status:
  edit: 1
  completed: 2
  uploaded: 3

The definitions in the mapping file cause the id column to be renamed to code, the name column to be renamed to title and the values of the status column to be mapped to numeric values (without changing the column title).

In addition to mapping column titles and field values, this tool can be used to change the character set encoding and the field separator. The default values are the UTF-8 encoding and the comma for both the input CSV and the output CSV.

Convert a Windows ANSI (Windows-1252) CSV file with semicolon field separators to UTF-8 with comma separators:

csvm -inputcharset=ansi -inputseparator=";" original.csv converted.csv

In this example it is not necessary to specify -outputcharset=utf8 and -outputseparator="," because those are the default values.

About

Command line tool to map column names and field values of a CSV file.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published