Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #46174
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <avnesh.nitk@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.002 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'detect': 0.07; 'json': 0.07; 'lines,': 0.07; 'subject:file': 0.07; 'subject:two': 0.07; 'subject:using': 0.09; 'cc:addr:python-list': 0.11; 'stored': 0.12; 'changes': 0.15; 'sorting': 0.16; 'subject:compare': 0.16; 'to:addr:pearwood.info': 0.16; 'to:addr:steve+comp.lang.python': 0.16; "to:name:steven d'aprano": 0.16; 'unordered': 0.16; 'unordered,': 0.16; 'subject:python': 0.16; 'wrote:': 0.18; 'file,': 0.19; 'value.': 0.19; 'cc:addr:python.org': 0.22; 'text,': 0.24; 'mon,': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; '>': 0.26; 'compare': 0.26; 'header:In-Reply- To:1': 0.27; 'idea': 0.28; 'correct': 0.29; 'am,': 0.29; 'message- id:@mail.gmail.com': 0.30; 'url:mailman': 0.30; 'gives': 0.31; '-0700,': 0.31; "d'aprano": 0.31; 'steven': 0.31; 'url:python': 0.33; 'checking': 0.33; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'data,': 0.36; 'library.': 0.36; 'skip:j 20': 0.36; 'url:listinfo': 0.36; 'thanks': 0.36; 'subject:?': 0.36; 'url:org': 0.36; 'wrong': 0.37; 'url:library': 0.38; 'url:mail': 0.40; 'how': 0.40; 'blank': 0.60; 'new': 0.61; 'hand,': 0.93; 'lot,': 0.93; 'yourself,': 0.95; '2013': 0.98 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=sOgGX/vsTzPQwMVFWyUgXnZrybHYY82KyHaad1xbqPU=; b=wtvtS/1D6PapuxtBpa2PAbQ++fV00Lin43miSMZN40+9QWg9quS6dEwE4eO30Ba9eo czMKJD/gA96r5STcpd+hfH+ey1WBODCn+1jdvVYAAvPZ1IIlxVzBD1kiEPN8jCgXafOL nG498e0eOO/91siDf/KnBjULMKGOKFTaMp53g7owvg5dB6aE8tCGSw2kzRmNP/cvvxZk T6bZ0wU3lSGuH1g+yWsRY/eg9paTK/DJwLqwQ0gMGjHmHYYb8PvulqZoOlbGu514hPlA rgZJF025skaDSemV4O3qPAWyx6x9cVoxCSK9Bylg6KJ9E7twdgLEdOSqxYq+OU5FhAun Emtw== |
| MIME-Version | 1.0 |
| X-Received | by 10.50.176.164 with SMTP id cj4mr4312713igc.66.1369636122933; Sun, 26 May 2013 23:28:42 -0700 (PDT) |
| In-Reply-To | <51a2f016$0$1744$c3e8da3$76491128@news.astraweb.com> |
| References | <355f934e-bda0-4316-96bb-583c498ecb1a@googlegroups.com> <51a2f016$0$1744$c3e8da3$76491128@news.astraweb.com> |
| Date | Mon, 27 May 2013 11:58:42 +0530 |
| Subject | Re: how to compare two json file line by line using python? |
| From | Avnesh Shakya <avnesh.nitk@gmail.com> |
| To | "Steven D'Aprano" <steve+comp.lang.python@pearwood.info> |
| Content-Type | multipart/alternative; boundary=089e0111d68494425304ddad4247 |
| Cc | python-list@python.org |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2237.1369636125.3114.python-list@python.org> (permalink) |
| Lines | 105 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1369636125 news.xs4all.nl 15894 [2001:888:2000:d::a6]:39959 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:46174 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
Thanks a lot, I got it.
On Mon, May 27, 2013 at 11:03 AM, Steven D'Aprano <
steve+comp.lang.python@pearwood.info> wrote:
> On Sun, 26 May 2013 21:32:40 -0700, Avnesh Shakya wrote:
>
> > But I want to compare line by line and value by value. but i found that
> > json data is unordered data, so how can i compare them without sorting
> > it. please give me some idea about it. I am new for it. I want to check
> > every value line by line.
>
> Why do you care about checking every value line by line? As you say
> yourself, JSON data is unordered, so "line by line" is the wrong way to
> compare it.
>
>
> The right way is to decode the JSON data, and then compare whether it
> gives you the result you expect:
>
> a = json.load("file-a")
> b = json.load("file-b")
> if a == b:
> print("file-a and file-b contain the same JSON data")
>
> If what you care about is the *data* stored in the JSON file, this is the
> correct way to check it.
>
> On the other hand, if you don't care about the data, but you want to
> detect changes to whitespace, blank lines, or other changes that make no
> difference to the JSON data, then there is no need to care that this is
> JSON data. Just treat it as text, and use the difflib library.
>
> http://docs.python.org/2/library/difflib.html
>
>
> --
> Steven
> --
> http://mail.python.org/mailman/listinfo/python-list
>
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
how to compare two json file line by line using python? Avnesh Shakya <avnesh.nitk@gmail.com> - 2013-05-26 21:32 -0700
Re: how to compare two json file line by line using python? rusi <rustompmody@gmail.com> - 2013-05-26 21:51 -0700
Re: how to compare two json file line by line using python? Avnesh Shakya <avnesh.nitk@gmail.com> - 2013-05-27 10:35 +0530
Re: how to compare two json file line by line using python? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-05-27 05:33 +0000
Re: how to compare two json file line by line using python? Avnesh Shakya <avnesh.nitk@gmail.com> - 2013-05-27 11:58 +0530
Re: how to compare two json file line by line using python? Grant Edwards <invalid@invalid.invalid> - 2013-05-28 16:00 +0000
Re: how to compare two json file line by line using python? Denis McMahon <denismfmcmahon@gmail.com> - 2013-05-27 10:50 +0000
csiph-web