Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/functionreturnfunction/format-table
Parse and reformat tabular data in emacs.
https://github.com/functionreturnfunction/format-table
emacs json library sql
Last synced: 3 months ago
JSON representation
Parse and reformat tabular data in emacs.
- Host: GitHub
- URL: https://github.com/functionreturnfunction/format-table
- Owner: functionreturnfunction
- Created: 2018-11-29T18:06:51.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2019-02-02T01:53:39.000Z (almost 6 years ago)
- Last Synced: 2024-04-14T03:00:02.067Z (7 months ago)
- Topics: emacs, json, library, sql
- Language: Emacs Lisp
- Size: 75.2 KB
- Stars: 8
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.org
Awesome Lists containing this project
README
* format-table [[https://travis-ci.org/functionreturnfunction/format-table][https://travis-ci.org/functionreturnfunction/format-table.png?branch=master]] [[https://coveralls.io/github/functionreturnfunction/format-table][https://img.shields.io/coveralls/github/functionreturnfunction/format-table/master.svg]] [[http://melpa.org/#/format-table][https://melpa.org/packages/format-table-badge.svg]]
Emacs can access many RDBMS systems via their command-line utilities using SQLi/comint, however each utility has its own output format for tables and affected row counts. This library allows for conversion between the output formats of many common RDBMS systems, as well as org tables and json.** Usage
#+BEGIN_SRC emacs-lisp
(format-table string-containing-table input-mode-to-match-string desired-output-mode)
#+END_SRCFor instance, to reformat an org-mode table, do the following:
#+BEGIN_SRC emacs-lisp
(let ((to-format
"
| Foo | Bar |
|-----+-----|
| 1 | 2 |
| 3 | 4 |"))
(format-table to-format 'org 'mysql))
#+END_SRCWhich will render the following output:
#+BEGIN_SRC
+-----+-----+
| Foo | Bar |
+-----+-----+
| 1 | 2 |
| 3 | 4 |
+-----+-----+
2 rows in set (0.00 sec)
#+END_SRC** Supported Formats
The following input/output formats are currently supported:
- ms
- org
- mysql
- postgresql
- jsonNew formats can be added by adding them to `format-table-format-alist' at runtime.
*** JSON note
Currently only exporting/importing arrays of hashes is supported. For instance, that previous org table:
#+BEGIN_SRC emacs-lisp
(let ((to-format
"
| Foo | Bar |
|-----+-----|
| 1 | 2 |
| 3 | 4 |"))
(format-table to-format 'org 'json))
#+END_SRCWill render as:
#+BEGIN_SRC javascript
[{"Foo":"1","Bar":"2"},{"Foo":"3","Bar":"4"}]
#+END_SRC