-
Notifications
You must be signed in to change notification settings - Fork 412
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- fix for #63, periods in column names - added json_loader CLI options - updated moving/locking of columns to be persisted to back-end as well as front-end - added the ability to show/hide columns - added column builder popup (#61)
- Loading branch information
Andrew Schonfeld
committed
Feb 19, 2020
1 parent
57b1e24
commit 1cd248f
Showing
40 changed files
with
1,302 additions
and
306 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import pandas as pd | ||
|
||
from dtale.cli.clickutils import get_loader_options | ||
|
||
''' | ||
IMPORTANT!!! These global variables are required for building any customized CLI loader. | ||
When build_loaders runs startup it will search for any modules containing the global variable LOADER_KEY. | ||
''' | ||
LOADER_KEY = 'json' | ||
LOADER_PROPS = [ | ||
dict(name='path', help='path to JSON file or URL to JSON endpoint'), | ||
dict(name='convert_dates', help='comma-separated string of column names which should be parsed as dates') | ||
] | ||
|
||
|
||
# IMPORTANT!!! This function is required for building any customized CLI loader. | ||
def find_loader(kwargs): | ||
""" | ||
CSV implementation of data loader which will return a function if any of the | ||
`click` options based on LOADER_KEY & LOADER_PROPS have been used, otherwise return None | ||
:param kwargs: Optional keyword arguments to be passed from `click` | ||
:return: data loader function for CSV implementation | ||
""" | ||
json_opts = get_loader_options(LOADER_KEY, kwargs) | ||
if len([f for f in json_opts.values() if f]): | ||
def _json_loader(): | ||
json_arg_parsers = { # TODO: add additional arg parsers | ||
'parse_dates': lambda v: v.split(',') if v else None | ||
} | ||
kwargs = {k: json_arg_parsers.get(k, lambda v: v)(v) for k, v in json_opts.items() if k != 'path'} | ||
return pd.read_json(json_opts['path'], **kwargs) | ||
return _json_loader | ||
return None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.