Created
May 1, 2017 07:09
-
-
Save tkf/36c80490bc6f6f2fcb90129ff8878616 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
def json2table(json_file, **kwds): | |
import pandas | |
df = pandas.read_json(json_file, **kwds) | |
df = df.set_index(df.columns[0]) | |
with pandas.option_context("display.max_rows", None, | |
"display.max_columns", None): | |
print(df) | |
def make_parser(doc=__doc__): | |
import argparse | |
parser = argparse.ArgumentParser(description=doc) | |
parser.add_argument('--orient', default='records') | |
parser.add_argument('json_file', type=argparse.FileType(), | |
nargs='?', default='-') | |
return parser | |
def main(args=None): | |
parser = make_parser() | |
ns = parser.parse_args(args) | |
json2table(**vars(ns)) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment