Title: How to tabulate JSON from stdin? · Issue #173 · astanin/python-tabulate · GitHub
Open Graph Title: How to tabulate JSON from stdin? · Issue #173 · astanin/python-tabulate
X Title: How to tabulate JSON from stdin? · Issue #173 · astanin/python-tabulate
Description: When I run a command like this: tabulate --format github - <<"EOF" [ { "column1": "data", "column2": 123, "column3": true, "column4": null }, { "column1": "Longer string", "column2": 123, "column3": true, "column4": null } ] EOF I expect...
Open Graph Description: When I run a command like this: tabulate --format github - <<"EOF" [ { "column1": "data", "column2": 123, "column3": true, "column4": null }, { "column1": "Longer string", "column2": 123, "column3"...
X Description: When I run a command like this: tabulate --format github - <<"EOF" [ { "column1": "data", "column2": 123, "column3": true, "column4"...
Opengraph URL: https://github.com/astanin/python-tabulate/issues/173
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"How to tabulate JSON from stdin?","articleBody":"When I run a command like this:\r\n\r\n```bash\r\ntabulate --format github - \u003c\u003c\"EOF\"\r\n[\r\n {\r\n \"column1\": \"data\",\r\n \"column2\": 123,\r\n \"column3\": true,\r\n \"column4\": null\r\n },\r\n {\r\n \"column1\": \"Longer string\",\r\n \"column2\": 123,\r\n \"column3\": true,\r\n \"column4\": null\r\n }\r\n]\r\nEOF\r\n```\r\n\r\nI expect output like this:\r\n\r\n```\r\n| column1 | column2 | column3 | column4 |\r\n|---------------|-----------|-----------|-----------|\r\n| data | 123 | True | |\r\n| Longer string | 123 | True | |\r\n```\r\n\r\nUnfortunately I get output like this:\r\n\r\n```\r\n|---|------------|---------|----------|\r\n| [ | | | |\r\n| | { | | |\r\n| | \"column1\": | \"data\", | |\r\n| | \"column2\": | 123, | |\r\n| | \"column3\": | true, | |\r\n| | \"column4\": | null | |\r\n| | }, | | |\r\n| | { | | |\r\n| | \"column1\": | \"Longer | string\", |\r\n| | \"column2\": | 123, | |\r\n| | \"column3\": | true, | |\r\n| | \"column4\": | null | |\r\n| | } | | |\r\n| ] | | | |\r\n```\r\n\r\n\r\nIn the README for the command-line utility I don't see any input format options or an expected input format.\r\n\r\nAs a library the README says tabulate supports \"list or another iterable of dicts (keys as columns)\". This matches my use case as it's what you would get after converting the input to via `json.load`\r\n\r\nAm I missing something?\r\n\r\nIf not, would you consider supporting this use case?\r\n\r\nCurrently I use jtbl for this (https://github.com/kellyjonbrazil/jtbl/issues/9) but I'd like tabulate to support it too as it has even more useful formatting options.\r\n\r\nIf it's not possible to guess the input format I'd accept something like an `--input-format json` similar to [in2csv](https://csvkit.readthedocs.io/en/latest/scripts/in2csv.html)'s `--format json` option.","author":{"url":"https://github.com/iainelder","@type":"Person","name":"iainelder"},"datePublished":"2022-03-31T07:54:03Z","url":"https://github.com/astanin/python-tabulate/issues/173"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:ed6f4ab6-e09a-1451-217f-f3c97caf40f1 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E286:2C041B:7C648:A6CEE:6AFF5DC0 |
| html-safe-nonce | d9069c46316b5a51c991d817375de1e81b3e2084d0f2925d0e2b685d0a95d77e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMjg2OjJDMDQxQjo3QzY0ODpBNkNFRTo2QUZGNURDMCIsInZpc2l0b3JfaWQiOiI1MzI2NTY1NjAxMzExNjc3ODg4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 7246d8b3e2da1eefffb71af12612bc22a42468a0330f976803165d8c0b2706ae |
| hovercard-subject-tag | issue:1187664164 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/astanin/python-tabulate/173/issue_layout |
| twitter:image | https://opengraph.githubassets.com/321a19a8dec5aade1b071ffa8a76d1f4f1a3cb6080e6f8c13206bede0b478a77/astanin/python-tabulate/issues/173 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/321a19a8dec5aade1b071ffa8a76d1f4f1a3cb6080e6f8c13206bede0b478a77/astanin/python-tabulate/issues/173 |
| og:image:alt | When I run a command like this: tabulate --format github - <<"EOF" [ { "column1": "data", "column2": 123, "column3": true, "column4": null }, { "column1": "Longer string", "column2": 123, "column3"... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | iainelder |
| hostname | github.com |
| expected-hostname | github.com |
| None | 2422ccd4bc783f932948cce4871cb9e0622bab749db07f387c9631b7e6834d1f |
| turbo-cache-control | no-preview |
| go-import | github.com/astanin/python-tabulate git https://github.com/astanin/python-tabulate.git |
| octolytics-dimension-user_id | 71802 |
| octolytics-dimension-user_login | astanin |
| octolytics-dimension-repository_id | 205875548 |
| octolytics-dimension-repository_nwo | astanin/python-tabulate |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 205875548 |
| octolytics-dimension-repository_network_root_nwo | astanin/python-tabulate |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 2a39546baeb98186e651a01d5d7aa6465825eeb1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width