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


Groups > comp.lang.python > #63672

Re: Send array back in result from urllib2.urlopen(request, postData)

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'output': 0.05; 'string.': 0.05; 'float': 0.07; 'none,': 0.07; 'string': 0.09; 'iterate': 0.09; 'mysql.': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'python': 0.11; 'jan': 0.12; 'brackets,': 0.16; 'comma.': 0.16; 'json,': 0.16; 'quoted': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'skip:[ 30': 0.16; 'splitting': 0.16; 'subject:array': 0.16; 'subject:skip:u 10': 0.16; 'wrote:': 0.18; 'subject:request': 0.19; 'rules': 0.22; 'print': 0.22; 'header:User-Agent:1': 0.23; 'parse': 0.24; 'looks': 0.24; "i've": 0.25; 'gets': 0.27; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'tried': 0.27; 'idea': 0.28; 'correct': 0.29; 'character': 0.29; "doesn't": 0.30; 'consisting': 0.31; 'end,': 0.31; 'quotes': 0.31; 'fri,': 0.33; "i'd": 0.34; 'subject:from': 0.34; 'but': 0.35; 'there': 0.35; 'list.': 0.37; 'starting': 0.37; 'to:addr:python- list': 0.38; 'anything': 0.39; 'embedded': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'according': 0.40; 'how': 0.40; 'subject:back': 0.60; 'back': 0.62; 'email addr:gmail.com': 0.63; 'anything.': 0.68; 'special': 0.74; '"j"': 0.84; 'received:myvzw.com': 0.84; 'subject:Send': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Dave Angel <davea@davea.name>
Subject Re: Send array back in result from urllib2.urlopen(request, postData)
Date Fri, 10 Jan 2014 18:12:46 -0500
References <aae37903-e5ab-41c5-87a7-2e3e78444878@googlegroups.com> <aae37903-e5ab-41c5-87a7-2e3e78444878@googlegroups.com>
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 8bit
X-Gmane-NNTP-Posting-Host 96.sub-70-208-129.myvzw.com
In-Reply-To <aae37903-e5ab-41c5-87a7-2e3e78444878@googlegroups.com>
User-Agent Groundhog Newsreader for Android
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 <https://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 <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.5310.1389395462.18130.python-list@python.org> (permalink)
Lines 51
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1389395462 news.xs4all.nl 2839 [2001:888:2000:d::a6]:40761
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:63672

Show key headers only | View raw


On Fri, 10 Jan 2014 12:57:59 -0800 (PST), vanommen.robert@gmail.com 
wrote:

No idea about the php..

> In python when i do 

> para = result.read()
> print para

> the output is:
> [null,null,null,null,null,"J"]

That's a string that just looks like a list.

> This is correct according to the data in PHP from the mysql.


> when I do 
> print para[1]

> the output is:

> n


> the seccond character from the data. Why is this not the seccond 
datafield?

There are no data fields in a string. 

> And why is para[5] not "J" but ,   ?

That's character 5 of the string.

> How can I change the data back to an array? I've tried with json, 
but that doesn't change anything.

You have to parse it. I don't know what rules you used at the php 
end, but at a guess, I'd start by stripping the brackets, then 
splitting by comma. Then iterate through each item looking for 
special cases. Each item consisting of null gets replaced by None, 
each item starting with quotes gets them stripped,  and perhaps 
anything else is replaced by float (item).

Still questions to ask like whether quoted item can have embedded 
comma.

-- 
DaveA

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


Thread

Send array back in result from urllib2.urlopen(request, postData) vanommen.robert@gmail.com - 2014-01-10 12:57 -0800
  Re: Send array back in result from urllib2.urlopen(request, postData) John Gordon <gordon@panix.com> - 2014-01-10 22:53 +0000
  Re: Send array back in result from urllib2.urlopen(request, postData) Dave Angel <davea@davea.name> - 2014-01-10 18:12 -0500
  Re: Send array back in result from urllib2.urlopen(request, postData) Denis McMahon <denismfmcmahon@gmail.com> - 2014-01-10 23:56 +0000
  Re: Send array back in result from urllib2.urlopen(request, postData) MRAB <python@mrabarnett.plus.com> - 2014-01-11 00:23 +0000
  Re: Send array back in result from urllib2.urlopen(request, postData) vanommen.robert@gmail.com - 2014-01-11 01:31 -0800

csiph-web