Which lib can diff two dict tree?

Discussion in 'Python' started by esbatmop@gmail.com, Jul 19, 2012.

  1. Guest

    Q1:
    dict a:{'a1': 'b1', 'a2': {'b2': 'c2'}, 'a3': 'b3'}
    dict b:{'a1': 'b1', 'a2': {'b2': 'c3'}}
    which lib can diff two dict tree?
    like:
    print struct_diff(a,b)
    >>tree 'a3'

    print value_diff(a,b)
    >>c3


    Q2
    How can I diff two json file?How can I get struct_diff and value_diff?

    Q3
    How can I diff two xml file? How can I get struct_diff and value_diff?
     
    , Jul 19, 2012
    #1
    1. Advertising

  2. alex23 Guest

    On Jul 19, 7:51 pm, wrote:
    > Q1:
    > which lib can diff two dict tree?
    > Q2
    > How can I diff two json file?How can I get struct_diff and value_diff?
    > Q3
    > How can I diff two xml file? How can I get struct_diff and value_diff?


    Rather than trying to come up with a method for finding the diffs of
    three different data structures, it might be easier to transform all
    the structures into the same form and then just use one mechanism for
    diffs.

    There's a 3rd-party python library for producing diffs of XML
    documents:
    http://www.logilab.org/projects/xmldiff

    Python dicts can be converted to XML using one of the suggestions
    here:
    http://stackoverflow.com/questions/1019895/serialize-python-dictionary-to-xml

    JSON can be transformed into dicts by using the standard library's
    json module.
     
    alex23, Jul 20, 2012
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Cyril Vi?ville

    diff Process under diff users

    Cyril Vi?ville, Jun 29, 2004, in forum: Perl
    Replies:
    1
    Views:
    529
    Joe Smith
    Jun 29, 2004
  2. Berrucho
    Replies:
    2
    Views:
    679
    Infant Newbie
    Dec 5, 2003
  3. A Traveler

    Diff CSS styles for diff INPUT TYPE='s?

    A Traveler, Aug 31, 2004, in forum: ASP .Net
    Replies:
    6
    Views:
    4,975
    Steve Fulton
    Aug 31, 2004
  4. James Yong
    Replies:
    0
    Views:
    594
    James Yong
    Sep 12, 2005
  5. Austin Ziegler

    [ANN] Diff::LCS 1.1.0, Diff::LCS 1.0.4

    Austin Ziegler, Aug 8, 2004, in forum: Ruby
    Replies:
    3
    Views:
    212
    Austin Ziegler
    Aug 9, 2004
Loading...

Share This Page