{ "info": { "author": "Takafumi Arakaki", "author_email": "aka.tkf@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "License :: OSI Approved :: BSD License", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.6", "Topic :: Software Development" ], "description": "Command line program & Python functions for comparing multiple dictionaries\n===========================================================================\n\n|pypi| |build-status| |coveralls|\n\n`dictsdiff` provides a CLI and Python interface for comparing\narbitrary number of nested dictionaries and show it as a tabular\nformat via pandas_.DataFrame.\n\n\nCLI\n---\n\nUsage::\n\n dictsdiff FILE [JSON_PATH] [FILE [JSON_PATH] ...]\n dictsdiff --ndjson=FILE.ndjson\n cat *.ndjson | dictsdiff [--ndjson=-]\n\nWhen paths to multiple files are given, it loads the dictionaries from\nthose files and compare (possibly) nested values in them. The\nkey-value pairs that are different or missing are shown in a table\nformat. A file path ``FILE`` may be followed by a JSONPath_\n``JSON_PATH`` which starts with ``$.``. If ``FILE`` starts with\n``$.``, prepend ``./`` to ``FILE`` to disambiguate the argument.\n``JSON_PATH`` can be used for non-JSON files.\n\n.. _JSONPath: http://goessner.net/articles/JsonPath/\n\nWhen no files are given, it is assumed that Newline delimited JSON\n(ndjson) is fed to the stdin.\n\nExamples\n^^^^^^^^\n\n.. code:: sh\n\n $ echo '{\"a\": 1, \"b\": {\"c\": 0, \"d\": 0, \"e\": 0}}' > 0.json\n $ echo '{\"a\": 2, \"b\": {\"c\": 0, \"d\": 1, \"e\": 0}}' > 1.json\n $ echo '{\"a\": 2, \"b\": {\"c\": 0, \"d\": 1}}' > 2.json\n $ dictsdiff *.json\n a b.d b.e\n path\n 0.json 1 0 0.0\n 1.json 2 1 0.0\n 2.json 2 1 NaN\n $ cat *.json | dictsdiff\n a b.d b.e\n 0 1 0 0.0\n 1 2 1 0.0\n 2 2 1 NaN\n\nIf JSON files are pre-processed by jq_, dictsdiff can handle its\noutput when ``--compact-output``/``-c`` is passed::\n\n jq --compact-output '' **/*.json | dictsdiff\n\nTo pass the original file path of JSON files to ``dictsdiff``, use\n``--info-key`` option combined with jq_'s ``input_filename``, e.g.,::\n\n jq --compact-output '.path = input_filename' **/*.json \\\n | dictsdiff --info-key=path\n\n.. _jq: https://stedolan.github.io/jq/\n\n\nPython interface\n----------------\n\n`dictsdiff.diff_dicts`\n^^^^^^^^^^^^^^^^^^^^^^\n\n>>> from dictsdiff import diff_dicts\n>>> dd = diff_dicts([\n... {'a': 1, 'b': {'c': 0, 'd': 0}},\n... {'a': 2, 'b': {'c': 0, 'd': 1}},\n... {'a': 1, 'b': {'c': 0, 'd': 1}},\n... ])\n>>> dd.keys\n[('a',), ('b', 'd')]\n>>> dd.pretty_diff()\n a b.d\n0 1 0\n1 2 1\n2 1 1\n\n\n`dictsdiff.diff_files`\n^^^^^^^^^^^^^^^^^^^^^^\n\n.. Run the code below in a clean temporary directory:\n >>> getfixture('cleancwd')\n\n>>> from dictsdiff import diff_files\n>>> _ = open('0.json', 'w').write('{\"a\": 1, \"b\": 2}')\n>>> _ = open('1.json', 'w').write('{\"a\": 1, \"b\": 3}')\n>>> dd = diff_files(['0.json', '1.json'])\n>>> dd.keys\n[('b',)]\n>>> dd.pretty_diff()\n b\npath \n0.json 2\n1.json 3\n\n\n`dictsdiff.diff_ndjson`\n^^^^^^^^^^^^^^^^^^^^^^^\n\n>>> import io\n>>> from dictsdiff import diff_ndjson\n>>> ndjson = u'''\n... {\"a\": 1, \"b\": {\"c\": 0, \"d\": 0}}\n... {\"a\": 2, \"b\": {\"c\": 0, \"d\": 1}}\n... '''.strip()\n>>> dd = diff_ndjson(io.StringIO(ndjson))\n>>> dd.keys\n[('a',), ('b', 'd')]\n>>> dd.pretty_diff()\n a b.d\n0 1 0\n1 2 1\n\n\nInstallation\n------------\n::\n\n pip install dictsdiff # or\n pip install https://github.com/tkf/dictsdiff/archive/master.zip\n\n\nRequirements\n^^^^^^^^^^^^\n\n- pandas_\n- PyYAML_ (optional)\n- toml_ (optional)\n- jsonpath-rw_ (optional)\n\n.. _pandas: http://pandas.pydata.org\n.. _PyYAML: http://pyyaml.org/wiki/PyYAML\n.. _toml: https://github.com/uiri/toml\n.. _jsonpath-rw: https://github.com/kennknowles/python-jsonpath-rw\n\n.. |pypi|\n image:: https://badge.fury.io/py/dictsdiff.svg\n :target: https://badge.fury.io/py/dictsdiff\n :alt: Python Package Index\n\n.. |build-status|\n image:: https://secure.travis-ci.org/tkf/dictsdiff.png?branch=master\n :target: http://travis-ci.org/tkf/dictsdiff\n :alt: Build Status\n\n.. |coveralls|\n image:: https://coveralls.io/repos/github/tkf/dictsdiff/badge.svg?branch=master\n :target: https://coveralls.io/github/tkf/dictsdiff?branch=master\n :alt: Test Coverage", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/tkf/dictsdiff", "keywords": "CLI,diff,JSON,YAML,Pickle", "license": "BSD-2-Clause", "maintainer": "", "maintainer_email": "", "name": "dictsdiff", "package_url": "https://pypi.org/project/dictsdiff/", "platform": "", "project_url": "https://pypi.org/project/dictsdiff/", "project_urls": { "Homepage": "https://github.com/tkf/dictsdiff" }, "release_url": "https://pypi.org/project/dictsdiff/0.1.1/", "requires_dist": null, "requires_python": "", "summary": "CLI & Python API for comparing multiple dictionaries", "version": "0.1.1" }, "last_serial": 4996060, "releases": { "0.0.0": [ { "comment_text": "", "digests": { "md5": "425affd04d8144ed064d143f8ad797cf", "sha256": "40bea13c87cdefd84689791e0bf492c25e999b8dc540f0dd47ca5f50df668ac1" }, "downloads": -1, "filename": "dictsdiff-0.0.0.tar.gz", "has_sig": false, "md5_digest": "425affd04d8144ed064d143f8ad797cf", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6302, "upload_time": "2017-06-26T01:59:24", "url": "https://files.pythonhosted.org/packages/1c/cf/25ac044f4207af1d2946e12f3dcd85d62d4e814cf9c1780bfecec0264768/dictsdiff-0.0.0.tar.gz" } ], "0.1.0": [ { "comment_text": "", "digests": { "md5": "085abc53ce17f9ef99edb0eddd1841ae", "sha256": "d9a35a53e25b0a645fe455b2a751466bf20b3eeac235623039f104eadf0474fc" }, "downloads": -1, "filename": "dictsdiff-0.1.0.tar.gz", "has_sig": false, "md5_digest": "085abc53ce17f9ef99edb0eddd1841ae", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12478, "upload_time": "2019-02-25T23:18:04", "url": "https://files.pythonhosted.org/packages/bc/67/a19069e00bf7912f9a8849929f14b6647557cb7ab5d6d90ab7093aff8f47/dictsdiff-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "5353df2b1bde662cd5ec8d6657336cce", "sha256": "8f810588de6bafdb2fc8b95dd40e45236a48c24fe8c868c8a3782a88d9056bea" }, "downloads": -1, "filename": "dictsdiff-0.1.1.tar.gz", "has_sig": false, "md5_digest": "5353df2b1bde662cd5ec8d6657336cce", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12528, "upload_time": "2019-03-28T05:11:49", "url": "https://files.pythonhosted.org/packages/c2/b1/74f09a68888f00a4da4a7507f67c1f8fe700f690b265dfd1e396cec6d8d7/dictsdiff-0.1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "5353df2b1bde662cd5ec8d6657336cce", "sha256": "8f810588de6bafdb2fc8b95dd40e45236a48c24fe8c868c8a3782a88d9056bea" }, "downloads": -1, "filename": "dictsdiff-0.1.1.tar.gz", "has_sig": false, "md5_digest": "5353df2b1bde662cd5ec8d6657336cce", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12528, "upload_time": "2019-03-28T05:11:49", "url": "https://files.pythonhosted.org/packages/c2/b1/74f09a68888f00a4da4a7507f67c1f8fe700f690b265dfd1e396cec6d8d7/dictsdiff-0.1.1.tar.gz" } ] }