tableconv 1.8__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- tableconv-1.8/.gitignore +91 -0
- tableconv-1.8/LICENSE +7 -0
- tableconv-1.8/PKG-INFO +297 -0
- tableconv-1.8/README.md +256 -0
- tableconv-1.8/pyproject.toml +93 -0
- tableconv-1.8/tableconv/__init__.py +20 -0
- tableconv-1.8/tableconv/__version__.py +3 -0
- tableconv-1.8/tableconv/adapters/__init__.py +0 -0
- tableconv-1.8/tableconv/adapters/df/__init__.py +25 -0
- tableconv-1.8/tableconv/adapters/df/ascii.py +130 -0
- tableconv-1.8/tableconv/adapters/df/aws_athena.py +333 -0
- tableconv-1.8/tableconv/adapters/df/aws_dynamodb.py +37 -0
- tableconv-1.8/tableconv/adapters/df/aws_logs.py +68 -0
- tableconv-1.8/tableconv/adapters/df/base.py +65 -0
- tableconv-1.8/tableconv/adapters/df/example.py +14 -0
- tableconv-1.8/tableconv/adapters/df/file_adapter_mixin.py +69 -0
- tableconv-1.8/tableconv/adapters/df/gsheets.py +438 -0
- tableconv-1.8/tableconv/adapters/df/jc.py +57 -0
- tableconv-1.8/tableconv/adapters/df/jira.py +13 -0
- tableconv-1.8/tableconv/adapters/df/json.py +215 -0
- tableconv-1.8/tableconv/adapters/df/leveldb.py +20 -0
- tableconv-1.8/tableconv/adapters/df/nested_list.py +95 -0
- tableconv-1.8/tableconv/adapters/df/numbers.py +32 -0
- tableconv-1.8/tableconv/adapters/df/osquery.py +43 -0
- tableconv-1.8/tableconv/adapters/df/pandas_io.py +238 -0
- tableconv-1.8/tableconv/adapters/df/pcap.py +73 -0
- tableconv-1.8/tableconv/adapters/df/python.py +39 -0
- tableconv-1.8/tableconv/adapters/df/rdbms.py +152 -0
- tableconv-1.8/tableconv/adapters/df/smart_sheet.py +72 -0
- tableconv-1.8/tableconv/adapters/df/sql_literal.py +24 -0
- tableconv-1.8/tableconv/adapters/df/sumo_logic.py +195 -0
- tableconv-1.8/tableconv/adapters/df/text_array.py +146 -0
- tableconv-1.8/tableconv/adapters/df/yaml.py +43 -0
- tableconv-1.8/tableconv/core.py +427 -0
- tableconv-1.8/tableconv/exceptions.py +118 -0
- tableconv-1.8/tableconv/in_memory_query.py +93 -0
- tableconv-1.8/tableconv/interactive.py +182 -0
- tableconv-1.8/tableconv/main.py +358 -0
- tableconv-1.8/tableconv/parse_time.py +21 -0
- tableconv-1.8/tableconv/uri.py +47 -0
- tableconv-1.8/tableconv_daemon/__init__.py +0 -0
- tableconv-1.8/tableconv_daemon/main.py +247 -0
tableconv-1.8/.gitignore
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
env/
|
|
12
|
+
build/
|
|
13
|
+
develop-eggs/
|
|
14
|
+
dist/
|
|
15
|
+
downloads/
|
|
16
|
+
eggs/
|
|
17
|
+
.eggs/
|
|
18
|
+
lib/
|
|
19
|
+
lib64/
|
|
20
|
+
parts/
|
|
21
|
+
sdist/
|
|
22
|
+
var/
|
|
23
|
+
*.egg-info/
|
|
24
|
+
.installed.cfg
|
|
25
|
+
*.egg
|
|
26
|
+
|
|
27
|
+
# PyInstaller
|
|
28
|
+
# Usually these files are written by a python script from a template
|
|
29
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
30
|
+
*.manifest
|
|
31
|
+
*.spec
|
|
32
|
+
|
|
33
|
+
# Installer logs
|
|
34
|
+
pip-log.txt
|
|
35
|
+
pip-delete-this-directory.txt
|
|
36
|
+
|
|
37
|
+
# Unit test / coverage reports
|
|
38
|
+
htmlcov/
|
|
39
|
+
.tox/
|
|
40
|
+
.coverage
|
|
41
|
+
.coverage.*
|
|
42
|
+
.cache
|
|
43
|
+
nosetests.xml
|
|
44
|
+
coverage.xml
|
|
45
|
+
*,cover
|
|
46
|
+
.hypothesis/
|
|
47
|
+
|
|
48
|
+
# Translations
|
|
49
|
+
*.mo
|
|
50
|
+
*.pot
|
|
51
|
+
|
|
52
|
+
# Django stuff:
|
|
53
|
+
*.log
|
|
54
|
+
|
|
55
|
+
# Flask stuff:
|
|
56
|
+
instance/
|
|
57
|
+
.webassets-cache
|
|
58
|
+
|
|
59
|
+
# Scrapy stuff:
|
|
60
|
+
.scrapy
|
|
61
|
+
|
|
62
|
+
# Sphinx documentation
|
|
63
|
+
docs/_build/
|
|
64
|
+
|
|
65
|
+
# IPython Notebook
|
|
66
|
+
.ipynb_checkpoints
|
|
67
|
+
|
|
68
|
+
# pyenv
|
|
69
|
+
.python-version
|
|
70
|
+
|
|
71
|
+
# celery beat schedule file
|
|
72
|
+
celerybeat-schedule
|
|
73
|
+
|
|
74
|
+
# dotenv
|
|
75
|
+
.env
|
|
76
|
+
|
|
77
|
+
# virtualenv
|
|
78
|
+
.venv/
|
|
79
|
+
venv/
|
|
80
|
+
ENV/
|
|
81
|
+
|
|
82
|
+
# Spyder project settings
|
|
83
|
+
.spyderproject
|
|
84
|
+
|
|
85
|
+
# Rope project settings
|
|
86
|
+
.ropeproject
|
|
87
|
+
*.npy
|
|
88
|
+
*.pkl
|
|
89
|
+
|
|
90
|
+
# MacOS debris
|
|
91
|
+
**/.DS_Store
|
tableconv-1.8/LICENSE
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright 2021 John Miller
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
tableconv-1.8/PKG-INFO
ADDED
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tableconv
|
|
3
|
+
Version: 1.8
|
|
4
|
+
Summary: CLI data plumbing tool
|
|
5
|
+
Project-URL: Homepage, https://github.com/personalcomputer/tableconv
|
|
6
|
+
Author-email: John Miller <john@johngm.com>
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
+
Classifier: Programming Language :: Python
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
12
|
+
Requires-Python: >=3.9
|
|
13
|
+
Requires-Dist: black
|
|
14
|
+
Requires-Dist: boto3
|
|
15
|
+
Requires-Dist: ciso8601
|
|
16
|
+
Requires-Dist: dpkt
|
|
17
|
+
Requires-Dist: duckdb
|
|
18
|
+
Requires-Dist: fastparquet
|
|
19
|
+
Requires-Dist: fsspec
|
|
20
|
+
Requires-Dist: genson
|
|
21
|
+
Requires-Dist: google-api-python-client
|
|
22
|
+
Requires-Dist: httplib2
|
|
23
|
+
Requires-Dist: lxml
|
|
24
|
+
Requires-Dist: marko
|
|
25
|
+
Requires-Dist: oauth2client
|
|
26
|
+
Requires-Dist: openpyxl
|
|
27
|
+
Requires-Dist: pandas>=2.0.0
|
|
28
|
+
Requires-Dist: pexpect
|
|
29
|
+
Requires-Dist: psycopg2-binary
|
|
30
|
+
Requires-Dist: pyarrow
|
|
31
|
+
Requires-Dist: pymysql
|
|
32
|
+
Requires-Dist: python-dateutil
|
|
33
|
+
Requires-Dist: pyyaml
|
|
34
|
+
Requires-Dist: sqlalchemy>=2.0.0
|
|
35
|
+
Requires-Dist: tables
|
|
36
|
+
Requires-Dist: tabulate
|
|
37
|
+
Requires-Dist: xlrd
|
|
38
|
+
Requires-Dist: xlsxwriter
|
|
39
|
+
Requires-Dist: xlwt
|
|
40
|
+
Description-Content-Type: text/markdown
|
|
41
|
+
|
|
42
|
+
# tableconv
|
|
43
|
+
|
|
44
|
+
tableconv is a prototype of software to convert tabular data from any format to any format.
|
|
45
|
+
|
|
46
|
+
## Install
|
|
47
|
+
|
|
48
|
+
```sh
|
|
49
|
+
pipx install tableconv
|
|
50
|
+
```
|
|
51
|
+
(or: `pip install tableconv`)
|
|
52
|
+
|
|
53
|
+
## Examples
|
|
54
|
+
|
|
55
|
+
### Basic Conversion
|
|
56
|
+
|
|
57
|
+
Convert JSON to CSV
|
|
58
|
+
```sh
|
|
59
|
+
tableconv test.json -o test.csv
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Convert CSV to JSON
|
|
63
|
+
```sh
|
|
64
|
+
tableconv test.csv -o test.json
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Dump a Postgres table as JSON
|
|
68
|
+
```sh
|
|
69
|
+
tableconv postgresql://192.168.0.10:5432/test_db/my_table -o my_table.json
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Display a parquet file's data in a human-readable format
|
|
73
|
+
```sh
|
|
74
|
+
tableconv test.parquet -o ascii:-
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Convert CSV to a Markdown Table
|
|
78
|
+
```sh
|
|
79
|
+
tableconv test.csv -o md:-
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Data Transformation
|
|
83
|
+
|
|
84
|
+
Dump the first 100 rows of a postgres table as JSON
|
|
85
|
+
```sh
|
|
86
|
+
tableconv postgresql://192.168.0.10:5432/test_db -q 'SELECT * FROM my_table ORDER BY id LIMIT 100' -o my_table.json
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Copy a few columns from one CSV into a new CSV.
|
|
90
|
+
(in general, all functionality works on all of the supported data formats. So you can of course query with SQL on an Oracle database but it's also supported to query with SQL on JSON, SQL on Excel, and, here SQL on CSV)
|
|
91
|
+
```sh
|
|
92
|
+
tableconv test.csv -q 'SELECT time, name FROM data ORDER BY time DESC' -o output.csv
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Append a few columns from a CSV into MySQL
|
|
96
|
+
```sh
|
|
97
|
+
tableconv test.csv -q 'SELECT time, name FROM data ORDER BY time DESC' -o mysql://localhost:3306/test_db/my_table?if_exists=append
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Extract a report from a SQLite database into a new Google Spreadsheet
|
|
101
|
+
```sh
|
|
102
|
+
tableconv sqlite3://my_db.db -q 'SELECT name, COUNT(*) from occurrences ORDER BY 2 DESC LIMIT 10' -o "gsheets://:new:/?name=top_occurrences_$(date +'%Y_%m_%d')"
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Interactive Mode
|
|
106
|
+
|
|
107
|
+
Launch an interactive SQL shell to inspect data from a CSV file in the terminal
|
|
108
|
+
```sh
|
|
109
|
+
tableconv test.csv -i
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Psuedo-Tabular Data Operations
|
|
113
|
+
|
|
114
|
+
Arrays: Arrays can be thought of as one dimensional tables, so tableconv has strong support for array formats too. Here
|
|
115
|
+
is an example of converting a copy/pasted newline-deliminated list into a list in the Python list syntax.
|
|
116
|
+
```sh
|
|
117
|
+
pbpaste | tableconv list:- -o pylist:-
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Or in YAML's sequence syntax:
|
|
121
|
+
```sh
|
|
122
|
+
pbpaste | tableconv list:- -o yamlsequence:-
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Or as a full single-dimensional CSV table:
|
|
126
|
+
```sh
|
|
127
|
+
pbpaste | tableconv list:- -o csv:-
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## Details
|
|
131
|
+
|
|
132
|
+
As a prototype, tableconv is usable as a quick and dirty CLI ETL tool for converting data between any of the formats, or usable for performing basic bulk data transformations and joins defined in a unified language (SQL) but operating across disparate data in wildly different formats. That is the immediate value proposition of tableconv, but it was created within the mental framework of a larger vision: The tableconv vision of computing is that all software fundamentally interfaces via data tables; that all UIs and APIs can be interpreted as data frames or data tables. Instead of requiring power users to learn interface after interface and build their own bespoke tooling to extract and manipulate the data at scale in each interface, the world needs a highly interoperable operating system level client for power users to directly interact with, join, and manipulate the data with SQL (or similar) using the universal "table" abstraction provided in a consistent UI across each service. Tableconv is that tool. It is meant to have adapters written to support any/all services and data formats.
|
|
133
|
+
|
|
134
|
+
However, this is just a prototype. The software is slow in all ways and memory+cpu intensive. It has no streaming support and loads all data into memory before converting it. Its most efficient adapters cannot handle tables over 10 million cells, and the least efficient cannot handle over 100000 cells. Schemas can migrate inconsistently depending upon the data available. It has experimental features that will not work reliably, such as schema management, the unorthodox URL scheme, and special array (1 dimensional table) support. All parts of the user interface are expected to be overhauled at some point. The code quality is mediocre, inconsistent, and bug-prone. Most obscure adapter options are untested. It has no story or documentation for service authentication, aside from SQL DBs. Lastly, the documentation is so weak that _no_ documentation exists documenting the standard options available for adapters adapter, nor documentation of any adapter-specific options.
|
|
135
|
+
|
|
136
|
+
## Usage
|
|
137
|
+
|
|
138
|
+
```
|
|
139
|
+
usage: tableconv SOURCE_URL [-q QUERY_SQL] [-o DEST_URL]
|
|
140
|
+
|
|
141
|
+
positional arguments:
|
|
142
|
+
SOURCE_URL Specify the data source URL.
|
|
143
|
+
|
|
144
|
+
options:
|
|
145
|
+
-h, --help show this help message and exit
|
|
146
|
+
-q, -Q, --query SOURCE_QUERY
|
|
147
|
+
Query to run on the source. Even for non-SQL datasources (e.g. csv or
|
|
148
|
+
json), SQL querying is still supported, try `SELECT * FROM data`.
|
|
149
|
+
-F, --filter INTERMEDIATE_FILTER_SQL
|
|
150
|
+
Filter (i.e. transform) the input data using a SQL query operating on the
|
|
151
|
+
dataset in memory using DuckDB SQL.
|
|
152
|
+
-o, --dest, --out, --output DEST_URL
|
|
153
|
+
Specify the data destination URL. If this destination already exists, be
|
|
154
|
+
aware that the default behavior is to overwrite.
|
|
155
|
+
-i, --interactive Enter interactive REPL query mode.
|
|
156
|
+
--open Open resulting file/url in the operating system desktop environment. (not
|
|
157
|
+
supported for all destination types)
|
|
158
|
+
--autocache, --cache Cache network data, and reuse cached data.
|
|
159
|
+
-v, --verbose, --debug
|
|
160
|
+
Show debug details, including API calls and error sources.
|
|
161
|
+
--version Show version number and exit
|
|
162
|
+
--quiet Only display errors.
|
|
163
|
+
--print, --print-dest
|
|
164
|
+
Print resulting URL/path to stdout, for chaining with other commands.
|
|
165
|
+
--schema, --coerce-schema SCHEMA_COERCION
|
|
166
|
+
Coerce source schema according to a schema definition. (WARNING:
|
|
167
|
+
experimental feature)
|
|
168
|
+
--restrict-schema Exclude all columns not included in the SCHEMA_COERCION definition.
|
|
169
|
+
(WARNING: experimental feature)
|
|
170
|
+
--daemon Tableconv startup time (python startup time) is slow. To mitigate that,
|
|
171
|
+
you can first run tableconv as a daemon, and then all future invocations
|
|
172
|
+
will be fast. (while daemon is still alive) (WARNING: experimental
|
|
173
|
+
feature)
|
|
174
|
+
|
|
175
|
+
supported url schemes:
|
|
176
|
+
ascii:- (dest only)
|
|
177
|
+
asciibox:- (dest only)
|
|
178
|
+
asciifancygrid:- (dest only)
|
|
179
|
+
asciigrid:- (dest only)
|
|
180
|
+
asciilite:- (dest only)
|
|
181
|
+
asciipipe:- (dest only)
|
|
182
|
+
asciiplain:- (dest only)
|
|
183
|
+
asciipresto:- (dest only)
|
|
184
|
+
asciipretty:- (dest only)
|
|
185
|
+
asciipsql:- (dest only)
|
|
186
|
+
asciisimple:- (dest only)
|
|
187
|
+
awsathena://eu-central-1
|
|
188
|
+
awsdynamodb://eu-central-1/example_table (source only)
|
|
189
|
+
awslogs://eu-central-1//aws/lambda/example-function (source only)
|
|
190
|
+
cmd://ls -l (source only)
|
|
191
|
+
csa:-
|
|
192
|
+
example.csv
|
|
193
|
+
example.dta
|
|
194
|
+
example.feather
|
|
195
|
+
example.fixedwidth
|
|
196
|
+
example.fwf
|
|
197
|
+
example.h5
|
|
198
|
+
example.hdf5
|
|
199
|
+
example.html
|
|
200
|
+
example.json
|
|
201
|
+
example.jsonl
|
|
202
|
+
example.jsonlines
|
|
203
|
+
example.ldjson
|
|
204
|
+
example.ndjson
|
|
205
|
+
example.numbers (source only)
|
|
206
|
+
example.odf
|
|
207
|
+
example.ods
|
|
208
|
+
example.odt
|
|
209
|
+
example.orc (source only)
|
|
210
|
+
example.parquet
|
|
211
|
+
example.pcap (source only)
|
|
212
|
+
example.pcapng (source only)
|
|
213
|
+
example.pickledf
|
|
214
|
+
example.py
|
|
215
|
+
example.python
|
|
216
|
+
example.tsv
|
|
217
|
+
example.xls
|
|
218
|
+
example.xlsb
|
|
219
|
+
example.xlsm
|
|
220
|
+
example.xlsx
|
|
221
|
+
example.yaml
|
|
222
|
+
example.yml
|
|
223
|
+
folder:///tmp/example (each file is considered a (filename,value) record)
|
|
224
|
+
gsheets://:new:
|
|
225
|
+
jc://ls -l (source only)
|
|
226
|
+
jiraformat:- (dest only)
|
|
227
|
+
jsonarray:-
|
|
228
|
+
jsondict:- (source only)
|
|
229
|
+
latex:- (dest only)
|
|
230
|
+
leveldblog:output-0 (source only)
|
|
231
|
+
list:-
|
|
232
|
+
markdown:- (dest only)
|
|
233
|
+
md:- (dest only)
|
|
234
|
+
mediawikiformat:- (dest only)
|
|
235
|
+
moinmoinformat:- (dest only)
|
|
236
|
+
mssql://127.0.0.1:5432/example_db
|
|
237
|
+
mysql://127.0.0.1:5432/example_db
|
|
238
|
+
nestedlist:-
|
|
239
|
+
oracle://127.0.0.1:5432/example_db
|
|
240
|
+
osquery://processes (source only)
|
|
241
|
+
postgis://127.0.0.1:5432/example_db
|
|
242
|
+
postgres://127.0.0.1:5432/example_db
|
|
243
|
+
postgresql://127.0.0.1:5432/example_db
|
|
244
|
+
pylist:-
|
|
245
|
+
pythonlist:-
|
|
246
|
+
rst:- (dest only)
|
|
247
|
+
sh://ls -l (source only)
|
|
248
|
+
smartsheet://SHEET_ID (source only)
|
|
249
|
+
sql_literal:- (dest only)
|
|
250
|
+
sql_values:- (dest only)
|
|
251
|
+
sqlite3:///tmp/example.db
|
|
252
|
+
sqlite:///tmp/example.db
|
|
253
|
+
sumologic://?from=2021-03-01T00:00:00Z&to=2021-05-03T00:00:00Z (source only)
|
|
254
|
+
tex:- (dest only)
|
|
255
|
+
tsa:-
|
|
256
|
+
yamlsequence:-
|
|
257
|
+
|
|
258
|
+
help & support:
|
|
259
|
+
https://github.com/personalcomputer/tableconv/issues/new
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
## Python API
|
|
263
|
+
|
|
264
|
+
### Quickstart Example: Basic API usage: Replicating a typical CLI command using the API
|
|
265
|
+
|
|
266
|
+
```python
|
|
267
|
+
In [1]: import tableconv
|
|
268
|
+
|
|
269
|
+
In [2]: # tableconv test.csv -q 'SELECT time, name FROM data ORDER BY time DESC' -o gsheets://:new:/?name=test
|
|
270
|
+
|
|
271
|
+
In [3]: tableconv.load_url('test.csv', query='SELECT time, name FROM data ORDER BY time DESC').dump_to_url('gsheets://:new:', params={'name': 'test'})
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
### Quickstart Example: More advanced API usage: Importing in data from an arbitrary URL to a python dictionary
|
|
275
|
+
|
|
276
|
+
```python
|
|
277
|
+
In [1]: import tableconv
|
|
278
|
+
|
|
279
|
+
In [2]: tableconv.load_url('postgresql://localhost:5432/test_db/cities').as_dict_records()
|
|
280
|
+
Out[2]:
|
|
281
|
+
[
|
|
282
|
+
{'LatD': 41, 'LatM': 5, 'LatS': 59, 'NS': 'N', 'LonD': 80, 'LonM': 39, 'LonS': 0, 'EW': 'W', 'City': 'Youngstown', 'State': 'OH'},
|
|
283
|
+
{'LatD': 42, 'LatM': 52, 'LatS': 48, 'NS': 'N', 'LonD': 97, 'LonM': 23, 'LonS': 23, 'EW': 'W', 'City': 'Yankton', 'State': 'SD'},
|
|
284
|
+
[...]
|
|
285
|
+
]
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
### SDK API Reference Documentation
|
|
289
|
+
|
|
290
|
+
(Reference documentation pending)
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
## Main Influences
|
|
294
|
+
- odo
|
|
295
|
+
- Singer
|
|
296
|
+
- ODBC/JDBC
|
|
297
|
+
- osquery
|
tableconv-1.8/README.md
ADDED
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
# tableconv
|
|
2
|
+
|
|
3
|
+
tableconv is a prototype of software to convert tabular data from any format to any format.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
pipx install tableconv
|
|
9
|
+
```
|
|
10
|
+
(or: `pip install tableconv`)
|
|
11
|
+
|
|
12
|
+
## Examples
|
|
13
|
+
|
|
14
|
+
### Basic Conversion
|
|
15
|
+
|
|
16
|
+
Convert JSON to CSV
|
|
17
|
+
```sh
|
|
18
|
+
tableconv test.json -o test.csv
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Convert CSV to JSON
|
|
22
|
+
```sh
|
|
23
|
+
tableconv test.csv -o test.json
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Dump a Postgres table as JSON
|
|
27
|
+
```sh
|
|
28
|
+
tableconv postgresql://192.168.0.10:5432/test_db/my_table -o my_table.json
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Display a parquet file's data in a human-readable format
|
|
32
|
+
```sh
|
|
33
|
+
tableconv test.parquet -o ascii:-
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Convert CSV to a Markdown Table
|
|
37
|
+
```sh
|
|
38
|
+
tableconv test.csv -o md:-
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Data Transformation
|
|
42
|
+
|
|
43
|
+
Dump the first 100 rows of a postgres table as JSON
|
|
44
|
+
```sh
|
|
45
|
+
tableconv postgresql://192.168.0.10:5432/test_db -q 'SELECT * FROM my_table ORDER BY id LIMIT 100' -o my_table.json
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Copy a few columns from one CSV into a new CSV.
|
|
49
|
+
(in general, all functionality works on all of the supported data formats. So you can of course query with SQL on an Oracle database but it's also supported to query with SQL on JSON, SQL on Excel, and, here SQL on CSV)
|
|
50
|
+
```sh
|
|
51
|
+
tableconv test.csv -q 'SELECT time, name FROM data ORDER BY time DESC' -o output.csv
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Append a few columns from a CSV into MySQL
|
|
55
|
+
```sh
|
|
56
|
+
tableconv test.csv -q 'SELECT time, name FROM data ORDER BY time DESC' -o mysql://localhost:3306/test_db/my_table?if_exists=append
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Extract a report from a SQLite database into a new Google Spreadsheet
|
|
60
|
+
```sh
|
|
61
|
+
tableconv sqlite3://my_db.db -q 'SELECT name, COUNT(*) from occurrences ORDER BY 2 DESC LIMIT 10' -o "gsheets://:new:/?name=top_occurrences_$(date +'%Y_%m_%d')"
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Interactive Mode
|
|
65
|
+
|
|
66
|
+
Launch an interactive SQL shell to inspect data from a CSV file in the terminal
|
|
67
|
+
```sh
|
|
68
|
+
tableconv test.csv -i
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Psuedo-Tabular Data Operations
|
|
72
|
+
|
|
73
|
+
Arrays: Arrays can be thought of as one dimensional tables, so tableconv has strong support for array formats too. Here
|
|
74
|
+
is an example of converting a copy/pasted newline-deliminated list into a list in the Python list syntax.
|
|
75
|
+
```sh
|
|
76
|
+
pbpaste | tableconv list:- -o pylist:-
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Or in YAML's sequence syntax:
|
|
80
|
+
```sh
|
|
81
|
+
pbpaste | tableconv list:- -o yamlsequence:-
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Or as a full single-dimensional CSV table:
|
|
85
|
+
```sh
|
|
86
|
+
pbpaste | tableconv list:- -o csv:-
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Details
|
|
90
|
+
|
|
91
|
+
As a prototype, tableconv is usable as a quick and dirty CLI ETL tool for converting data between any of the formats, or usable for performing basic bulk data transformations and joins defined in a unified language (SQL) but operating across disparate data in wildly different formats. That is the immediate value proposition of tableconv, but it was created within the mental framework of a larger vision: The tableconv vision of computing is that all software fundamentally interfaces via data tables; that all UIs and APIs can be interpreted as data frames or data tables. Instead of requiring power users to learn interface after interface and build their own bespoke tooling to extract and manipulate the data at scale in each interface, the world needs a highly interoperable operating system level client for power users to directly interact with, join, and manipulate the data with SQL (or similar) using the universal "table" abstraction provided in a consistent UI across each service. Tableconv is that tool. It is meant to have adapters written to support any/all services and data formats.
|
|
92
|
+
|
|
93
|
+
However, this is just a prototype. The software is slow in all ways and memory+cpu intensive. It has no streaming support and loads all data into memory before converting it. Its most efficient adapters cannot handle tables over 10 million cells, and the least efficient cannot handle over 100000 cells. Schemas can migrate inconsistently depending upon the data available. It has experimental features that will not work reliably, such as schema management, the unorthodox URL scheme, and special array (1 dimensional table) support. All parts of the user interface are expected to be overhauled at some point. The code quality is mediocre, inconsistent, and bug-prone. Most obscure adapter options are untested. It has no story or documentation for service authentication, aside from SQL DBs. Lastly, the documentation is so weak that _no_ documentation exists documenting the standard options available for adapters adapter, nor documentation of any adapter-specific options.
|
|
94
|
+
|
|
95
|
+
## Usage
|
|
96
|
+
|
|
97
|
+
```
|
|
98
|
+
usage: tableconv SOURCE_URL [-q QUERY_SQL] [-o DEST_URL]
|
|
99
|
+
|
|
100
|
+
positional arguments:
|
|
101
|
+
SOURCE_URL Specify the data source URL.
|
|
102
|
+
|
|
103
|
+
options:
|
|
104
|
+
-h, --help show this help message and exit
|
|
105
|
+
-q, -Q, --query SOURCE_QUERY
|
|
106
|
+
Query to run on the source. Even for non-SQL datasources (e.g. csv or
|
|
107
|
+
json), SQL querying is still supported, try `SELECT * FROM data`.
|
|
108
|
+
-F, --filter INTERMEDIATE_FILTER_SQL
|
|
109
|
+
Filter (i.e. transform) the input data using a SQL query operating on the
|
|
110
|
+
dataset in memory using DuckDB SQL.
|
|
111
|
+
-o, --dest, --out, --output DEST_URL
|
|
112
|
+
Specify the data destination URL. If this destination already exists, be
|
|
113
|
+
aware that the default behavior is to overwrite.
|
|
114
|
+
-i, --interactive Enter interactive REPL query mode.
|
|
115
|
+
--open Open resulting file/url in the operating system desktop environment. (not
|
|
116
|
+
supported for all destination types)
|
|
117
|
+
--autocache, --cache Cache network data, and reuse cached data.
|
|
118
|
+
-v, --verbose, --debug
|
|
119
|
+
Show debug details, including API calls and error sources.
|
|
120
|
+
--version Show version number and exit
|
|
121
|
+
--quiet Only display errors.
|
|
122
|
+
--print, --print-dest
|
|
123
|
+
Print resulting URL/path to stdout, for chaining with other commands.
|
|
124
|
+
--schema, --coerce-schema SCHEMA_COERCION
|
|
125
|
+
Coerce source schema according to a schema definition. (WARNING:
|
|
126
|
+
experimental feature)
|
|
127
|
+
--restrict-schema Exclude all columns not included in the SCHEMA_COERCION definition.
|
|
128
|
+
(WARNING: experimental feature)
|
|
129
|
+
--daemon Tableconv startup time (python startup time) is slow. To mitigate that,
|
|
130
|
+
you can first run tableconv as a daemon, and then all future invocations
|
|
131
|
+
will be fast. (while daemon is still alive) (WARNING: experimental
|
|
132
|
+
feature)
|
|
133
|
+
|
|
134
|
+
supported url schemes:
|
|
135
|
+
ascii:- (dest only)
|
|
136
|
+
asciibox:- (dest only)
|
|
137
|
+
asciifancygrid:- (dest only)
|
|
138
|
+
asciigrid:- (dest only)
|
|
139
|
+
asciilite:- (dest only)
|
|
140
|
+
asciipipe:- (dest only)
|
|
141
|
+
asciiplain:- (dest only)
|
|
142
|
+
asciipresto:- (dest only)
|
|
143
|
+
asciipretty:- (dest only)
|
|
144
|
+
asciipsql:- (dest only)
|
|
145
|
+
asciisimple:- (dest only)
|
|
146
|
+
awsathena://eu-central-1
|
|
147
|
+
awsdynamodb://eu-central-1/example_table (source only)
|
|
148
|
+
awslogs://eu-central-1//aws/lambda/example-function (source only)
|
|
149
|
+
cmd://ls -l (source only)
|
|
150
|
+
csa:-
|
|
151
|
+
example.csv
|
|
152
|
+
example.dta
|
|
153
|
+
example.feather
|
|
154
|
+
example.fixedwidth
|
|
155
|
+
example.fwf
|
|
156
|
+
example.h5
|
|
157
|
+
example.hdf5
|
|
158
|
+
example.html
|
|
159
|
+
example.json
|
|
160
|
+
example.jsonl
|
|
161
|
+
example.jsonlines
|
|
162
|
+
example.ldjson
|
|
163
|
+
example.ndjson
|
|
164
|
+
example.numbers (source only)
|
|
165
|
+
example.odf
|
|
166
|
+
example.ods
|
|
167
|
+
example.odt
|
|
168
|
+
example.orc (source only)
|
|
169
|
+
example.parquet
|
|
170
|
+
example.pcap (source only)
|
|
171
|
+
example.pcapng (source only)
|
|
172
|
+
example.pickledf
|
|
173
|
+
example.py
|
|
174
|
+
example.python
|
|
175
|
+
example.tsv
|
|
176
|
+
example.xls
|
|
177
|
+
example.xlsb
|
|
178
|
+
example.xlsm
|
|
179
|
+
example.xlsx
|
|
180
|
+
example.yaml
|
|
181
|
+
example.yml
|
|
182
|
+
folder:///tmp/example (each file is considered a (filename,value) record)
|
|
183
|
+
gsheets://:new:
|
|
184
|
+
jc://ls -l (source only)
|
|
185
|
+
jiraformat:- (dest only)
|
|
186
|
+
jsonarray:-
|
|
187
|
+
jsondict:- (source only)
|
|
188
|
+
latex:- (dest only)
|
|
189
|
+
leveldblog:output-0 (source only)
|
|
190
|
+
list:-
|
|
191
|
+
markdown:- (dest only)
|
|
192
|
+
md:- (dest only)
|
|
193
|
+
mediawikiformat:- (dest only)
|
|
194
|
+
moinmoinformat:- (dest only)
|
|
195
|
+
mssql://127.0.0.1:5432/example_db
|
|
196
|
+
mysql://127.0.0.1:5432/example_db
|
|
197
|
+
nestedlist:-
|
|
198
|
+
oracle://127.0.0.1:5432/example_db
|
|
199
|
+
osquery://processes (source only)
|
|
200
|
+
postgis://127.0.0.1:5432/example_db
|
|
201
|
+
postgres://127.0.0.1:5432/example_db
|
|
202
|
+
postgresql://127.0.0.1:5432/example_db
|
|
203
|
+
pylist:-
|
|
204
|
+
pythonlist:-
|
|
205
|
+
rst:- (dest only)
|
|
206
|
+
sh://ls -l (source only)
|
|
207
|
+
smartsheet://SHEET_ID (source only)
|
|
208
|
+
sql_literal:- (dest only)
|
|
209
|
+
sql_values:- (dest only)
|
|
210
|
+
sqlite3:///tmp/example.db
|
|
211
|
+
sqlite:///tmp/example.db
|
|
212
|
+
sumologic://?from=2021-03-01T00:00:00Z&to=2021-05-03T00:00:00Z (source only)
|
|
213
|
+
tex:- (dest only)
|
|
214
|
+
tsa:-
|
|
215
|
+
yamlsequence:-
|
|
216
|
+
|
|
217
|
+
help & support:
|
|
218
|
+
https://github.com/personalcomputer/tableconv/issues/new
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
## Python API
|
|
222
|
+
|
|
223
|
+
### Quickstart Example: Basic API usage: Replicating a typical CLI command using the API
|
|
224
|
+
|
|
225
|
+
```python
|
|
226
|
+
In [1]: import tableconv
|
|
227
|
+
|
|
228
|
+
In [2]: # tableconv test.csv -q 'SELECT time, name FROM data ORDER BY time DESC' -o gsheets://:new:/?name=test
|
|
229
|
+
|
|
230
|
+
In [3]: tableconv.load_url('test.csv', query='SELECT time, name FROM data ORDER BY time DESC').dump_to_url('gsheets://:new:', params={'name': 'test'})
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
### Quickstart Example: More advanced API usage: Importing in data from an arbitrary URL to a python dictionary
|
|
234
|
+
|
|
235
|
+
```python
|
|
236
|
+
In [1]: import tableconv
|
|
237
|
+
|
|
238
|
+
In [2]: tableconv.load_url('postgresql://localhost:5432/test_db/cities').as_dict_records()
|
|
239
|
+
Out[2]:
|
|
240
|
+
[
|
|
241
|
+
{'LatD': 41, 'LatM': 5, 'LatS': 59, 'NS': 'N', 'LonD': 80, 'LonM': 39, 'LonS': 0, 'EW': 'W', 'City': 'Youngstown', 'State': 'OH'},
|
|
242
|
+
{'LatD': 42, 'LatM': 52, 'LatS': 48, 'NS': 'N', 'LonD': 97, 'LonM': 23, 'LonS': 23, 'EW': 'W', 'City': 'Yankton', 'State': 'SD'},
|
|
243
|
+
[...]
|
|
244
|
+
]
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
### SDK API Reference Documentation
|
|
248
|
+
|
|
249
|
+
(Reference documentation pending)
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
## Main Influences
|
|
253
|
+
- odo
|
|
254
|
+
- Singer
|
|
255
|
+
- ODBC/JDBC
|
|
256
|
+
- osquery
|