Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #46380
| Date | 2013-05-29 16:04 +0200 |
|---|---|
| From | Ervin Hegedüs <airween@gmail.com> |
| Subject | Re: detect key conflict in a JSON file |
| References | <mailman.2347.1369826248.3114.python-list@python.org> <roy-5C9415.09253929052013@news.panix.com> <CAOuJsMkzEZGEK0gVDMYNk3y3PDgn7+nYxwur_U6=_kaUMKSGUw@mail.gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2359.1369836452.3114.python-list@python.org> (permalink) |
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.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
detect key conflict in a JSON file Jabba Laci <jabba.laci@gmail.com> - 2013-05-29 13:16 +0200
Re: detect key conflict in a JSON file Roy Smith <roy@panix.com> - 2013-05-29 09:25 -0400
Re: detect key conflict in a JSON file Jabba Laci <jabba.laci@gmail.com> - 2013-05-29 15:41 +0200
Re: detect key conflict in a JSON file rusi <rustompmody@gmail.com> - 2013-05-29 07:36 -0700
Re: detect key conflict in a JSON file Ervin Hegedüs <airween@gmail.com> - 2013-05-29 16:04 +0200
Re: detect key conflict in a JSON file Roy Smith <roy@panix.com> - 2013-05-29 11:20 -0400
Re: detect key conflict in a JSON file Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-05-30 03:10 +0000
csiph-web