Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder1.xlned.com!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.060 X-Spam-Evidence: '*H*': 0.90; '*S*': 0.02; 'package,': 0.03; 'duplicate': 0.07; 'json': 0.07; 'subject:file': 0.07; 'cc:addr :python-list': 0.11; 'python': 0.11; 'dictionary,': 0.16; 'modul': 0.16; 'started?': 0.16; 'subject:key': 0.16; 'yaml': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'first.': 0.19; 'import': 0.22; 'python?': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**1': 0.23; 'header:User-Agent:1': 0.23; 'library,': 0.24; 'second': 0.26; 'header:In-Reply-To:1': 0.27; "i'm": 0.30; 'struct': 0.31; 'probably': 0.32; 'linux': 0.33; 'no,': 0.35; 'but': 0.35; '+0200,': 0.36; 'thanks': 0.36; 'files': 0.38; 'how': 0.40; 'read': 0.60; 'skip:y 20': 0.60; 'most': 0.60; 'ago,': 0.61; 'from:charset:utf-8': 0.61; 'content-disposition:inline': 0.62; 'real': 0.63; 'different': 0.65; 'to:addr:gmail.com': 0.65; 'here': 0.66; 'hints': 0.68; 'silently': 0.84; 'received:86': 0.91; 'choice.': 0.93; 'lot,': 0.93; 'received:hu': 0.93; '2013': 0.98 X-Spam-Flag: NO X-Spam-Score: -1.892 X-Spam-Level: X-Spam-Status: No, score=-1.892 tagged_above=-20 required=4 tests=[ALL_TRUSTED=-1, AWL=0.106, BAYES_00=-1.9, DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001, NML_ADSP_CUSTOM_MED=0.9] autolearn=no Date: Wed, 29 May 2013 16:04:00 +0200 From: Ervin =?utf-8?Q?Heged=C3=BCs?= To: Jabba Laci Subject: Re: detect key conflict in a JSON file References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) Cc: Python mailing list , Roy Smith X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 45 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1369836452 news.xs4all.nl 15916 [2001:888:2000:d::a6]:49649 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:46380 Hello, On Wed, May 29, 2013 at 03:41:50PM +0200, Jabba Laci wrote: > > The real answer here is that JSON is probably not the best choice for > > large files that get hand-edited. For data that you intend to hand-edit > > a lot, YAML might be a better choice. > > > >> Currently the value of the second key silently overwrites the value of > >> the first. > > Thanks but how would it be different with YAML? Can YAML check duplicate keys? no, I think it can't, I'm using yaml a few months ago, as I noticed, the last key prevail. > How to process (read) YAML files in Python? Can you give me some hints > how to get started? All I need is read it in and create a dictionary > of it. import yaml struct = yaml.load(file("yamlfile.yml" 'r')) and struct will be a Python dictionary, As I know, yaml modul is not part of standard Python library, but most Linux systems has package, eg. Debian/Ubuntu has a "python-yaml". Cheers: a.