Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #92974

Re: JSON Object to CSV file

From Denis McMahon <denismfmcmahon@gmail.com>
Newsgroups comp.lang.python
Subject Re: JSON Object to CSV file
Date 2015-06-21 20:52 +0000
Organization A noiseless patient Spider
Message-ID <mm7879$n8l$1@dont-email.me> (permalink)
References <dd791644-35b4-4400-a683-d409808c0c5b@googlegroups.com> <mm5mj6$5m8$3@dont-email.me> <e1a0eb4d-9594-480f-b082-142dc566dea2@googlegroups.com>

Show all headers | View raw


On Sun, 21 Jun 2015 06:57:01 -0700, sahluwalia wrote:

> On Sunday, 21 June 2015 02:47:31 UTC-4, Denis McMahon  wrote:
>> On Wed, 17 Jun 2015 08:00:11 -0700, Saran A wrote:
>> 
>> > I would like to have this JSON object written out to a CSV file so
>> > that the keys are header fields (for each of the columns) and the
>> > values are values that are associated with each header field.
>> 
>> > {
>> > "CF": {
>> .......
>> > "CF": "Fee",
>> 
>> Your json object seems to have the same key used for two elements at
>> the same level, are you sure this is legal json?

> I converted this from an XML file given to me from a third party. It is
> as is. I am not sure what you mean by "valid"; that is a very subjective
> measure for any form of quantitative or qualitative data.

Put it this way, when I feed your json object into a jason lint, the 
output is the following:

{
    "CF": "Fee",
    "ID": "2"
}

The second occurrence in the parent object of name "CF" with a value of 
string literal "Fee" overwrites the earlier name "CF" whose value is (in 
python terms) a dictionary or (in json terms) an object.

-- 
Denis McMahon, denismfmcmahon@gmail.com

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

JSON Object to CSV file Saran A <ahlusar.ahluwalia@gmail.com> - 2015-06-17 08:00 -0700
  Re: JSON Object to CSV file Sahlusar <ahlusar.ahluwalia@gmail.com> - 2015-06-17 08:45 -0700
    Re: JSON Object to CSV file Peter Otten <__peter__@web.de> - 2015-06-17 20:19 +0200
      Re: JSON Object to CSV file Sahlusar <ahlusar.ahluwalia@gmail.com> - 2015-06-17 13:20 -0700
  Re: JSON Object to CSV file Denis McMahon <denismfmcmahon@gmail.com> - 2015-06-21 06:45 +0000
    Re: JSON Object to CSV file sahluwalia@wynyardgroup.com - 2015-06-21 06:57 -0700
      Re: JSON Object to CSV file Denis McMahon <denismfmcmahon@gmail.com> - 2015-06-21 20:52 +0000
        Re: JSON Object to CSV file Sahlusar <ahlusar.ahluwalia@gmail.com> - 2015-06-21 16:38 -0700
    Re: JSON Object to CSV file Sahlusar <ahlusar.ahluwalia@gmail.com> - 2015-06-21 07:22 -0700
    Re: JSON Object to CSV file Sahlusar <ahlusar.ahluwalia@gmail.com> - 2015-06-21 07:54 -0700
      Re: JSON Object to CSV file Ned Batchelder <ned@nedbatchelder.com> - 2015-06-21 08:31 -0700
        Re: JSON Object to CSV file Sahlusar <ahlusar.ahluwalia@gmail.com> - 2015-06-21 08:39 -0700
  Re: JSON Object to CSV file ryguy7272 <ryanshuell@gmail.com> - 2015-08-19 18:54 -0700

csiph-web