Skip to content

[MIRROR] Reshape delimited text files

License

Notifications You must be signed in to change notification settings

adigitoleo/reshape

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Building reshape requires a Nim compiler (version 1.4.8 or later).

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

Debug build: nim c src/reshape.nim

Test

The test suite requires unittest2.

Run nimble test in the source code root directory.

Linux CI (dev build): 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.

Contribute

Please submit patches or suggestions to the project mailing list. Patches should be submitted against the HEAD of the dev branch on SourceHut. Pull Requests on the GitHub mirror are not monitored.

Similar solutions

TODO

  • More high-level tests (test examples from manual page?)
  • extract/generate help proc text from the mdoc source?
  • documentation for --skip{rows,cols}=1-2-3 (start-step-stop) syntax
  • better upfront error handling

Languages