json2xls Documentation

Similar documents
bottle-rest Release 0.5.0

xmljson Documentation

API Wrapper Documentation

django-auditlog Documentation

Watson - Events. Release 1.0.3

df2gspread Documentation

linkgrabber Documentation

python-docker-machine Documentation

[301] JSON. Tyler Caraza-Harter

Flask-Cors Documentation

pydrill Documentation

corenlp-xml-reader Documentation

django-embed-video Documentation

TPS Documentation. Release Thomas Roten

f5-icontrol-rest Documentation

bzz Documentation Release Rafael Floriano and Bernardo Heynemann

PyOTP Documentation. Release PyOTP contributors

ejpiaj Documentation Release Marek Wywiał

django-dynamic-db-router Documentation

Watson - DB. Release 2.7.0

pysharedutils Documentation

iqoptionapi Release Jan 13, 2018

maya-cmds-help Documentation

PyZabbixObj Documentation

Reminder About Functions

Traits CLI Documentation

Scrapy-Redis Documentation

GitHub-Flask Documentation

Types, lists & functions

MyGeotab Python SDK Documentation

Unicum Documentation. Release alpha. Deutsche Postbank AG

redis-completion Documentation

streamio Documentation

sainsmart Documentation

Django-CSP Documentation

Case study: accessing financial data

Pulp Python Support Documentation

CSC148 Recipe for Designing Classes

pyautocad Documentation

Flask-SimpleLDAP Documentation

CS1114 Spring 2015 Test ONE ANSWER KEY. page 1 of 8 pages (counting the cover sheet)

Python easy mail library Documentation

Flask-Twilio Documentation

mprpc Documentation Release Studio Ousia

Interactive Fiction Language (IFL)

Gearthonic Documentation

Pypeline Documentation

Manhattan Documentation

StyleFrame Documentation. Release latest

YouTube API Wrapper Documentation

BanzaiDB Documentation

Snakemine: Redmine API wrapper Documentation

IoT Relay Documentation

flask-jwt-simple Documentation

StyleFrame Documentation. Release stable

Neustar TDI Documentation

JSONRPC Documentation

InfluxDB Documentation

Roman Numeral Converter Documentation

goose3 Documentation Release maintainers

BibtexParser Documentation

yagmail Documentation

django-oauth2-provider Documentation

Lecture 7. Memory in Python

Python State Machine Documentation

pglib Documentation Release Michael Kleehammer

Bitdock. Release 0.1.0

sanction Documentation

django-crucrudile Documentation

Large-Scale Networks

scieloapi.py Documentation

PyDriller Documentation

eventbrite-sdk-python Documentation

django-slim Documentation

DoJSON Documentation. Release Invenio collaboration

python-idex Documentation

python-jose Documentation

Google Domain Shared Contacts Client Documentation

pyshk Documentation Release Jeremy Low

tolerance Documentation

json-rpc Documentation

django-avatar Documentation

Python wrapper for Viscosity.app Documentation

python-oauth2 Documentation

Python Finite State Machine. Release 0.1.5

lala Documentation Release 0.5.dev103+gfd01df0 Wieland Hoffmann

treelib Documentation

bosonnlp.py Documentation

django-embed-video Documentation

tapi Documentation Release 0.1 Jimmy John

Connexion Sqlalchemy Utils Documentation

python-json-patch Documentation

Python Best Practices

Harness the power of Python magic methods and lazy objects.

Marshmallow-Mongoengine Documentation

pyregion Documentation

WordEmbeddingLoader Documentation

py-couchdb Documentation

pyexcel-pygal Documentation

chatterbot-weather Documentation

Transcription:

json2xls Documentation Release 0.1.3c axiaoxin Aug 10, 2017

Contents 1 3 2 5 3 API 9 i

ii

json2xls Documentation, Release 0.1.3c jsonexceljsonexceljson jsonjsonurljsonjson Contents 1

json2xls Documentation, Release 0.1.3c 2 Contents

CHAPTER 1 json2xls GitHub PyPI pip : $ pip install json2xls : $ python setup.py install json2xls MIT 3

json2xls Documentation, Release 0.1.3c 4 Chapter 1.

CHAPTER 2 API: from json2xls import Json2Xls # jsonexcel json_data = u'''[ {"": "John", "": 30, "": ""}, {"": "Alice", "": 18, "": ""} ]''' obj = Json2Xls('tests/json_strlist_test.xls', json_data) obj.make() # getjsonexcel params = { 'location': u'', 'output': 'json', 'ak': '5slgyqGDENN7Sy7pw29IUvrZ' } Json2Xls('tests/url_get_test.xls', "http://httpbin.org/get", params=params).make() # postjsonexcel post_data = { 'location': u'', 'output': 'json', 'ak': '5slgyqGDENN7Sy7pw29IUvrZ' } Json2Xls('tests/url_post_test1.xls', "http://httpbin.org/post", method='post', post_ data=post_data, form_encoded=true).make() # post_data post_data = 'tests/post_data.json' Json2Xls('tests/url_post_test2.xls', "http://httpbin.org/post", method='post', post_ data=post_data, form_encoded=true).make() # jsonexcel 5

json2xls Documentation, Release 0.1.3c obj = Json2Xls('tests/json_line_test.xls', json_data='tests/line_data.json') obj.make() # jsonexcel Json2Xls('tests/json_list_test.xls', json_data='tests/list_data.json').make() # excel def title_callback(self, data): '''use one of data record to generate excel title''' self.sheet.write_merge(0, 0, 0, 3, 'title', self.title_style) self.sheet.write_merge(1, 2, 0, 0, 'tag', self.title_style) self.sheet.write_merge(1, 2, 1, 1, 'ner', self.title_style) self.sheet.write_merge(1, 1, 2, 3, 'comment', self.title_style) self.sheet.row(2).write(2, 'x', self.title_style) self.sheet.row(2).write(3, 'y', self.title_style) self.sheet.write_merge(0, 0, 4, 7, 'body', self.title_style) self.sheet.write_merge(1, 2, 4, 4, 'tag', self.title_style) self.sheet.write_merge(1, 2, 5, 5, 'ner', self.title_style) self.sheet.write_merge(1, 1, 6, 7, 'comment', self.title_style) self.sheet.row(2).write(6, 'x', self.title_style) self.sheet.row(2).write(7, 'y', self.title_style) self.start_row += 3 def body_callback(self, data): key1 = ['title', 'body'] key2 = ['tag', 'ner', 'comment'] col = 0 for ii, i in enumerate(key1): for ij, j in enumerate(key2): if j!= 'comment': value = ', '.join(data[ii][i][j]) self.sheet.row(self.start_row).write(col, value) col += 1 else: for x in data[ii][i][j].values(): self.sheet.row(self.start_row).write(col, x) col += 1 self.start_row += 1 data = 'tests/callback_data.json' j = Json2Xls('tests/callback.xls', data) j.make(title_callback=title_callback, body_callback=body_callback) : # from json string json2xls tests/cmd_str_test.xls '{"a":"a", "b":"b"}' json2xls tests/cmd_str_test1.xls '[{"a":"a", "b":"b"},{"a":1, "b":2}]' # from file: whole file is a complete json data json2xls tests/cmd_list_test.xls "`cat tests/list_data.json`" # from file: each line is a json data json2xls tests/cmd_line_test.xls tests/line_data.json 6 Chapter 2.

json2xls Documentation, Release 0.1.3c # from url json2xls tests/cmd_get_test.xls http://httpbin.org/get json2xls tests/cmd_post_test.xls http://httpbin.org/post -m post -d '"hello json2xls" ' -h "{'X-Token': 'bolobolomi'}" 7

json2xls Documentation, Release 0.1.3c 8 Chapter 2.

CHAPTER 3 API class json2xls.json2xls(xls_filename, json_data, method= get, params=none, post_data=none, headers=none, form_encoded=false, dumps=false, sheet_name= sheet0, title_style=none) Json2Xls API Parameters xls_filename (string) excel json_data (string) json jsonurl json json method (string) urlurl get params (dict) get None post_data (dict) post None headers (dict) urlhttp (json) form_encoded (bool) post False sheet_name (string) Excelsheet sheet0 title_style (string) Excel None json_dumps (function) ensure_asciijson.dumps() False json_loads (function) object_pairs_hookjson.loads() dumps (bool) exceljson_dumps False auto_width(row, col, value) Parameters row (int) col (int) value (int) 9

json2xls Documentation, Release 0.1.3c flatten(data_dict, parent_key=, sep=. ) dictflattendict Parameters data_dict (dict) dict parent_key (str) key sep (str) key flatten. make(title_callback=none, body_callback=none) Excel Parameters title_callback (func) Execl None body_callback (func) Execl None 10 Chapter 3. API

Index A auto_width() (json2xls.json2xls method), 9 F flatten() (json2xls.json2xls method), 9 J Json2Xls (class in json2xls), 9 json2xls (module), 1 M make() (json2xls.json2xls method), 10 11