{"id":22433637,"url":"https://github.com/nlitsme/transpose","last_synced_at":"2025-08-01T12:34:06.436Z","repository":{"id":57474736,"uuid":"186809016","full_name":"nlitsme/transpose","owner":"nlitsme","description":"Command line tool for transforming matrices of textual data","archived":false,"fork":false,"pushed_at":"2023-08-22T20:06:32.000Z","size":11,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-01T18:47:53.674Z","etag":null,"topics":["columns","matrix","python","rotate","textutil","transpose"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nlitsme.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-05-15T11:02:58.000Z","updated_at":"2023-08-22T20:06:35.000Z","dependencies_parsed_at":"2022-09-10T02:22:19.178Z","dependency_job_id":null,"html_url":"https://github.com/nlitsme/transpose","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nlitsme%2Ftranspose","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nlitsme%2Ftranspose/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nlitsme%2Ftranspose/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nlitsme%2Ftranspose/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nlitsme","download_url":"https://codeload.github.com/nlitsme/transpose/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228377529,"owners_count":17910449,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["columns","matrix","python","rotate","textutil","transpose"],"created_at":"2024-12-05T22:15:30.801Z","updated_at":"2024-12-05T22:15:31.536Z","avatar_url":"https://github.com/nlitsme.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# transpose\nCommand line tool for transforming row/column formatted textual data.\n\nOften you have data formatted in rows and columns in some way, this tool\nallows one to specify how your data in each line is organised in columns.\n`transpose` can transform the matrix formed by the columns and rows in\nseveral ways. You can transpose, rotate by multiples of 45 or 90 degrees.\nOr flip the data vertically, or horizontally.\n\nThe default action is to transpose ( swap rows with columns ).\n\nSeveral ways of defining what consists a 'column':\n\n* fixed width columns.\n* using a separator pattern, default: '`\\t|,\\s*| +`'\n  - TAB or COMMA followed by optional whitespace or SPACES\n* by a column pattern, example: '`\\s+\\w+`'\n* separator with quoted strings, often used in CSV files.\n\nIn the output the separator is either the single character separator specified with the `-t` option,\nor, when the separator is a pattern, a TAB charater is used.\n\nData is either read from stdin, or from files specified on the commandline.\n\n# Install\n\nYou can instal `transpose` from [pypi](https://pypi.org/project/text-transpose/1.0.0/) using `pip`:\n\n    pip install text-transpose\n\n# Usage\n\n    usage: transpose.py [-h] [--test] [--verbose] [-t SEPARATOR] [-p PATTERN]\n                        [-w WIDTH] [-l] [-a] [-q] [-Q] [--yflip] [--xflip]\n                        [--rotate DEG] [+180] [+90] [-90] [+45] [-45] [--skew]\n                        [DAT [DAT ...]]\n\n    transform a matrix, default: transpose\n\n    positional arguments:\n      DAT\n\n    optional arguments:\n      -h, --help            show this help message and exit\n      --test                run unittest\n      --verbose, -v\n      -t SEPARATOR, --separator SEPARATOR\n                            column separator\n      -p PATTERN, --pattern PATTERN\n                            column pattern, example: \\s+\\w+\n      -w WIDTH, --width WIDTH\n                            Fixed width columns, alow multiple widths. Either a\n                            comma separated list of widths, with the last value\n                            taken for the remaining columns. ( 5,1,1,10 )\n                            Optionally a width can be prefixed with a column\n                            number followed by a colon. ( 5:1,7:1,8 )\n      -l, --keepspaces      Leading whitespace is relevant\n      -q, --quoted          Quoted strings with C style escapes ( using backslash\n                            )in columns.\n      -Q, --dquoted         Quoted strings with SQL style escapes ( using repeated\n                            quotes ) in columns.\n      --yflip, -y           reverse each line\n      --xflip, -x, --tac    like \"tac\", output lines in reverse order\n      --rotate DEG          Rotate by multiple of 45 degrees\n      +180, -180            rotate by 180 degrees\n      +90                   rotate by 90 degrees counter-clockwise\n      -90                   rotate by 90 degrees clockwise\n      +45                   rotate by 45 degrees counter-clockwise\n      -45                   rotate by 45 degrees clockwise\n      --skew                rotate by 45 degrees clockwise, but de-indent\n\n    Specify negative numbers using: --rotate=-45\n\n\n# Example\n\n## split the output of `ls` into columns, and transpose:\n\n    ls -al | transpose -w 10,5,6,7,7,12\n\nNOTE: this depends on the actual rendering by `ls`, column widths may vary.\n\nAlternatively, you could split the output of `ls` into columns using:\n\n    ls -al | transpose -p \"\\S+\\s*\" -t,\n\n## Swap columns and rows:\n\n    cat \u003c\u003c__EOF__ | transpose\n    a b c\n    d e f\n    __EOF__\n\nWill result in:\n\n    a   d   \n    b   e   \n    c   f   \n\n## Rotate by 45 degrees\n\n    cat \u003c\u003c__EOF__ | transpose -45\n    a b c\n    d e f\n    g h i\n    __EOF__\n\nResults in:\n\n            a       \n        d       b   \n    g       e       c\n        h       f   \n            i       \n\n\n## reverse column order\n\n    cat \u003c\u003c__EOF__ | transpose -y\n    a b c\n    d e f\n    __EOF__\n\nWill result in:\n\n    c   b   a\n    f   e   d\n\n## reverse a line\n\n    transpose -y -w 1\n    transpose -y -p .\n\n## reverse words in a line\n\n    transpose -y -t \" \"\n\n## reverse a list of lines\n\nLike `tac`:\n\n    transpose -x\n\n# TODO\n\n * Handle multiline quoted values.\n * Add option to specify regex extracting columns from entire line.\n * Add option to left/right-align columns in the output.\n * Add option to retain separators with their column value.\n   - you can already kind of do this using the --pattern option.\n * I thought about adding options to change the way values are quoted, and separated,\n   now i think that is better left to a different tool. So for now i will just leave\n   the quoting and escaping intact, like it is.\n * Add option to specify an output separator.\n\n# Author\nWillem Hengeveld \u003citsme@xs4all.nl\u003e \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnlitsme%2Ftranspose","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnlitsme%2Ftranspose","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnlitsme%2Ftranspose/lists"}