Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Which lib can diff two dict tree?

Reply
Thread Tools

Which lib can diff two dict tree?

 
 
esbatmop@gmail.com
Guest
Posts: n/a
 
      07-19-2012
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?
 
Reply With Quote
 
 
 
 
alex23
Guest
Posts: n/a
 
      07-20-2012
On Jul 19, 7:51Â*pm, esbat...@gmail.com 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/1...tionary-to-xml

JSON can be transformed into dicts by using the standard library's
json module.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Diff betw common/lib and shared/lib in Tomcat James Yong Java 0 09-12-2005 02:36 AM
Diff CSS styles for diff INPUT TYPE='s? A Traveler ASP .Net 6 08-31-2004 09:17 PM
[ANN] Diff::LCS 1.1.0, Diff::LCS 1.0.4 Austin Ziegler Ruby 3 08-09-2004 06:34 AM
diff Process under diff users Cyril Vi?ville Perl 1 06-29-2004 06:22 PM
Same sessionID retuned to diff browsers in diff machines Berrucho ASP .Net 2 12-05-2003 02:23 PM



Advertisments