".esnes sekam ti wonk uoY .daer ot ysae os sgniht ekam seod yllaer ti
,niaga gnitsop potrof s'knahT"
On 30/08/2015 12:38, Sven R. Kunze wrote:
Well, it comes down to "can he switch from JSON to YAML" in the first
place as he is going to parse "by-third-party" generated json. So, if he
can pers
On Sat, 29 Aug 2015 02:15 am, Robin Koch wrote:
> Am 28.08.2015 um 18:09 schrieb Sven R. Kunze:
>
> >> I'm reading JSON output from an input file, and extracting values.
> >
>> for proper parsing into native Python types, I would recommend YAML.
>
> "What's the best way to get from A to B?"
>
Well, it comes down to "can he switch from JSON to YAML" in the first
place as he is going to parse "by-third-party" generated json. So, if he
can persuade MongoDB to output YAML instead, he would be all fine.
Just my 2 cents.
On 28.08.2015 18:15, Robin Koch wrote:
Am 28.08.2015 um 18:09 schr
Am 28.08.2015 um 18:09 schrieb Sven R. Kunze:
>> I'm reading JSON output from an input file, and extracting values.
>
for proper parsing into native Python types, I would recommend YAML.
"What's the best way to get from A to B?"
"I recommend starting at C."
- Every other usenet-discussion.
-
Hey Victor,
for proper parsing into native Python types, I would recommend YAML.
Also also supports (besides int vs. float) dates and datetimes.
Cheers,
Sven
On 28.08.2015 07:04, Victor Hooi wrote:
Actually, I've just realised, if I just test for numeric or try to cast to
ints, this will bre
On Fri, Aug 28, 2015 at 5:56 PM, Victor Hooi wrote:
>
> Currently I'm using this:
>
> def strip_floatApprox_wrapping(field):
> # Extracts a integer value from a field. Workaround for the float_approx
> wrapping.
> if isinstance(field, dict):
> return field['floatApprox']
> els
Hi,
Thanks heaps to everybody for their suggestions/advice =).
Currently I'm using this:
def strip_floatApprox_wrapping(field):
# Extracts a integer value from a field. Workaround for the float_approx
wrapping.
if isinstance(field, dict):
return field['floatApprox']
else:
Ben Finney writes:
> Victor Hooi writes:
[- -]
>> For example:
>>
>> {
>> "hostname": "example.com",
>> "version": "3.0.5",
>> "pid": {
>> "floatApprox": 18403
>> }
>> "network": {
>> "bytesIn": 123123,
>> "bytesOut": {
>> "floatApprox": 2131
Ben Finney writes:
> Victor Hooi writes:
>
>> Many of the fields are meant to be numerical, however, some fields are
>> wrapped in a "floatApprox" dict, which messed with my parsing.
>
> The examples you give of ‘floatApprox’ are not dicts, so I'm not sure
> quite what that means.
I took the dist
I suspect your code will have these 2 lines in it somewhere ...
if isinstance(field, dict):
return int(field['floatApprox'])
using isinstance() or type() is generally frowned upon because
it breaks duck typing, and makes it necessary for you to write more
code every time somebody wants to feed
On Fri, Aug 28, 2015, at 00:57, Victor Hooi wrote:
> I'm reading JSON output from an input file, and extracting values.
>
> Many of the fields are meant to be numerical, however, some fields are
> wrapped in a "floatApprox" dict, which messed with my parsing.
> Is there a way to re-write strip_flo
Victor Hooi writes:
> I'm reading JSON output from an input file, and extracting values.
>
> Many of the fields are meant to be numerical, however, some fields are
> wrapped in a "floatApprox" dict, which messed with my parsing.
>
> For example:
>
> {
> "hostname": "example.com",
> "versio
Victor Hooi writes:
> Many of the fields are meant to be numerical, however, some fields are
> wrapped in a "floatApprox" dict, which messed with my parsing.
The examples you give of ‘floatApprox’ are not dicts, so I'm not sure
quite what that means.
> For example:
>
> {
> "hostname": "exam
Actually, I've just realised, if I just test for numeric or try to cast to
ints, this will break for string fields.
As in, the intention is to call strip_floatAprox_wrapping on all the fields I'm
parsing, and have it deal with the floatApprox dict wrapping, whether the
contents are numbers or s
I'm reading JSON output from an input file, and extracting values.
Many of the fields are meant to be numerical, however, some fields are wrapped
in a "floatApprox" dict, which messed with my parsing.
For example:
{
"hostname": "example.com",
"version": "3.0.5",
"pid": {
"fl
15 matches
Mail list logo