~adigitoleo/reshape

Reshape delimited text files

df386ca docs: Update readme references and todo list

25 days ago

3e13a50 style: Run nimpretty over the code

28 days ago

#reshape

Reshape delimited text files.

Reads input from a file if the filename is given as the last argument. Reads from stdin stream (e.g. unix pipe) otherwise, until terminated by an EOF signal. A filename argument of - can also be used to switch to stdin input. Note that the whole input is read into memory at once for processing.

#Features

This utility can process tabular data by

  • transposing rows with columns
  • reshaping the data, e.g. turning a 4x4 table into a 8x2 table,
  • skipping selected rows/columns (individual or ranges),
  • deduplicating repeated rows,
  • padding cells to right-align table columns,
  • and printing information about input tables (e.g. number of rows/columns, number of malformed rows)

For some usage examples, refer to the manual page. If you have installed reshape, you should be able to read it from man reshape. Otherwise the manual page source can be rendered on most Unix systems using man -l /path/to/reshape.1.mdoc.

#Install

After building the reshape binary, put it in one of your $PATH directories. The manual page in the doc folder should also be copied into the appropriate manual page folder for your system.

#Build

Release build: nim c -d:release src/reshape.nim

Debug build: nim c src/reshape.nim

#Test

Run nimble test in the source code root directory.

Linux CI (latest release): builds.sr.ht status

#Use

Run with the --help option if built, or check the printHelp proc in the code. Note that short options must not be separated from their arguments by a space. Use : or = instead, or append the argument to the option flag directly. This behaviour is inherited from Nim's parseopt module.

#Similar solutions

#TODO

  • More high-level tests (test examples from manual page?)
  • extract/generate help proc text from the mdoc source?