Reshape delimited text files

a7c9bb6 feat: Support '\s' syntax for space delimiter

4 months ago

8af7320 docs: Update README todo list

6 months ago


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.



printf 'a,b,c'|reshape -d, -t


printf '%s\n%s\n' 'a,b,c' '1,2,3'|reshape -d, -s3x2

Output is right-aligned by default (use -p or --nopad to disable):

printf '%s\n%s\n%s\n' 'a,b,c' '1,2,3' 'foo,bar,baz'|reshape -d,
  a,  b,  c
  1,  2,  3

Skip individual rows/columns or ranges:

printf '%s\n%s\n%s\n' 'a,b,c' '1,2,3' 'foo,bar,baz'|reshape -d, -r:1 -c:1-2

Note that unicode symbols are currently not aligned properly:

printf '%s\n%s\n%s\n' ',a,b,c,d' ',1,2,3,4' ',",",,ß'|reshape -d, -c1 -s3x4
  a,b, c,d
  1,2, 3,4
",", ,ß,


After building the reshape binary, put it in one of your $PATH directories.


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

Debug build: nim c src/reshape.nim


Run nimble test in the source code root directory.

Linux CI (dev branch): builds.sr.ht status


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


  • Fix cell padding for tables with unicode characters.