You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Ayhan Kesenci <a....@googlemail.com> on 2015/02/04 01:37:47 UTC

Fwd: Export question

I export a view with a curl command

and the view looks like this in the map

function(doc) {
emit([doc.user.friends_count,
doc.user.followers_count,doc.retweet_count,doc.text], doc.id_str);
}


is it possible to surround the for example doc.user.friends_count with
quote signs, to have it like this with the usual comma between the quote
signs?


"doc.user.friends_count","
doc.user.followers_count","doc.retweet_count","doc.text"

thank you

2015-02-04 1:31 GMT+01:00 Ayhan Kesenci <a....@googlemail.com>:

> I export a view with a curl command
>
> and the view looks like this in the map
>
> function(doc) {
> emit([doc.user.friends_count,
> doc.user.followers_count,doc.retweet_count,doc.text], doc.id_str);
> }
>
>
> is it possible to surround the for example doc.user.friends_count with
> quote signs, to have it like this with the usual comma between the quote
> signs?
>
>
> "doc.user.friends_count","
> doc.user.followers_count","doc.retweet_count","doc.text"
>
>

Re: Export question

Posted by Ayhan Kesenci <a....@googlemail.com>.
So it is easier to export a view with string and integers :) and import in
csv

2015-02-05 20:05 GMT+01:00 Giovanni P <fi...@gmail.com>:

> Why do you want that? Values that are surrounded by quotes are strings. Do
> you want strings? You just need to convert your values to strings when
> emitting them, like
>
> function(doc) {
>   emit([doc.user.friends_count.toString(), doc.user.followers_count
> .toString(), doc.retweet_count.toString(), doc.text], doc.id_str);
> }
>
> On Tue, Feb 3, 2015 at 10:37 PM, Ayhan Kesenci <a.kesenci89@googlemail.com
> >
> wrote:
>
> > I export a view with a curl command
> >
> > and the view looks like this in the map
> >
> > function(doc) {
> > emit([doc.user.friends_count,
> > doc.user.followers_count,doc.retweet_count,doc.text], doc.id_str);
> > }
> >
> >
> > is it possible to surround the for example doc.user.friends_count with
> > quote signs, to have it like this with the usual comma between the quote
> > signs?
> >
> >
> > "doc.user.friends_count","
> > doc.user.followers_count","doc.retweet_count","doc.text"
> >
> > thank you
> >
> > 2015-02-04 1:31 GMT+01:00 Ayhan Kesenci <a....@googlemail.com>:
> >
> > > I export a view with a curl command
> > >
> > > and the view looks like this in the map
> > >
> > > function(doc) {
> > > emit([doc.user.friends_count,
> > > doc.user.followers_count,doc.retweet_count,doc.text], doc.id_str);
> > > }
> > >
> > >
> > > is it possible to surround the for example doc.user.friends_count with
> > > quote signs, to have it like this with the usual comma between the
> quote
> > > signs?
> > >
> > >
> > > "doc.user.friends_count","
> > > doc.user.followers_count","doc.retweet_count","doc.text"
> > >
> > >
> >
>

Re: Export question

Posted by Giovanni P <fi...@gmail.com>.
Why do you want that? Values that are surrounded by quotes are strings. Do
you want strings? You just need to convert your values to strings when
emitting them, like

function(doc) {
  emit([doc.user.friends_count.toString(), doc.user.followers_count
.toString(), doc.retweet_count.toString(), doc.text], doc.id_str);
}

On Tue, Feb 3, 2015 at 10:37 PM, Ayhan Kesenci <a....@googlemail.com>
wrote:

> I export a view with a curl command
>
> and the view looks like this in the map
>
> function(doc) {
> emit([doc.user.friends_count,
> doc.user.followers_count,doc.retweet_count,doc.text], doc.id_str);
> }
>
>
> is it possible to surround the for example doc.user.friends_count with
> quote signs, to have it like this with the usual comma between the quote
> signs?
>
>
> "doc.user.friends_count","
> doc.user.followers_count","doc.retweet_count","doc.text"
>
> thank you
>
> 2015-02-04 1:31 GMT+01:00 Ayhan Kesenci <a....@googlemail.com>:
>
> > I export a view with a curl command
> >
> > and the view looks like this in the map
> >
> > function(doc) {
> > emit([doc.user.friends_count,
> > doc.user.followers_count,doc.retweet_count,doc.text], doc.id_str);
> > }
> >
> >
> > is it possible to surround the for example doc.user.friends_count with
> > quote signs, to have it like this with the usual comma between the quote
> > signs?
> >
> >
> > "doc.user.friends_count","
> > doc.user.followers_count","doc.retweet_count","doc.text"
> >
> >
>

Re: Strange issue with dates

Posted by Kiril Stankov <ki...@open-net.biz>.
Sorry,

simply pasting from Futon...
Ignore them.

"SetCancelled": "function(doc,req) {doc['cancelled']=true; 
doc['cancelledDate']=Date.now(); return [doc, 'ok'];}",
"SetLastVisit": "function(doc,req) {doc['lastvisit']=Date.now(); return 
[doc, 'ok'];}"

&

"cancelled": true,
"cancelledDate": "2015-01-10T00:34:19.654Z",
"lastvisit": 1423181473571

------------------------------------------------------------------------
*With best regards,*
Kiril Stankov,
CEO


            This Email disclaimer
            <http://open-net.biz/emailsignature.html> is integral part
            of this message.

On 2/6/2015 2:12 AM, Giovanni P wrote:
> what is this formatting you're using? it is really difficult to read all
> those |||
>
> On Thu, Feb 5, 2015 at 10:07 PM, Kiril Stankov <ki...@open-net.biz> wrote:
>
>> Hi,
>>
>> I have two update handlers:
>>
>> ||"|SetCancelled|":|"function(doc,req) {doc['cancelled']=true;
>> doc['cancelledDate']=Date.now(); return [doc, 'ok'];}"|,
>> "|SetLastVisit|":|"function(doc,req) {doc['lastvisit']=Date.now(); return
>> [doc, 'ok'];}"
>>
>>
>> |||
>>
>> How can it be one is writing the date as Unix date, and the other as Java
>> Date??
>>
>> |    "|cancelled|":|true|,
>>     "|cancelledDate|":|"2015-02-03T00:34:19.654Z"|,
>>     "|lastvisit|":|1423180381094||
>>
>>
>> I call them one after the other?
>>
>> Thanks in advance!
>> ------------------------------------------------------------------------
>> *With best regards,*
>> Kiril Stankov
>>
>>


Re: Strange issue with dates

Posted by Giovanni P <fi...@gmail.com>.
what is this formatting you're using? it is really difficult to read all
those |||

On Thu, Feb 5, 2015 at 10:07 PM, Kiril Stankov <ki...@open-net.biz> wrote:

> Hi,
>
> I have two update handlers:
>
> ||"|SetCancelled|":|"function(doc,req) {doc['cancelled']=true;
> doc['cancelledDate']=Date.now(); return [doc, 'ok'];}"|,
> "|SetLastVisit|":|"function(doc,req) {doc['lastvisit']=Date.now(); return
> [doc, 'ok'];}"
>
>
> |||
>
> How can it be one is writing the date as Unix date, and the other as Java
> Date??
>
> |    "|cancelled|":|true|,
>    "|cancelledDate|":|"2015-02-03T00:34:19.654Z"|,
>    "|lastvisit|":|1423180381094||
>
>
> I call them one after the other?
>
> Thanks in advance!
> ------------------------------------------------------------------------
> *With best regards,*
> Kiril Stankov
>
>

Re: Strange issue with dates

Posted by Kiril Stankov <ki...@open-net.biz>.
Thanks,

actually, this what I want to do... use unix epoch.
But for some reason one is written as date.
Still investigating...

------------------------------------------------------------------------
*With best regards,*
Kiril Stankov

On 2/6/2015 2:27 AM, Stanley Iriele wrote:
> There is probably something off happening when parsing dates between what's
> stored on disk in erlang what's sent back. Remember dates are not a thing
> in JSON.
>
> My advice would be to NEVER STORE DATES.  "New date().getTime()" and just
> get the milliseconds...and when you want to use it use new
> date(<milliseconds>). I've personally been bitten by date weirdness So its
> best to work with something thats "interpret safe"
> On Feb 5, 2015 4:09 PM, "Kiril Stankov" <ki...@open-net.biz> wrote:
>
>> Hi,
>>
>> I have two update handlers:
>>
>> ||"|SetCancelled|":|"function(doc,req) {doc['cancelled']=true;
>> doc['cancelledDate']=Date.now(); return [doc, 'ok'];}"|,
>> "|SetLastVisit|":|"function(doc,req) {doc['lastvisit']=Date.now(); return
>> [doc, 'ok'];}"
>>
>>
>> |||
>>
>> How can it be one is writing the date as Unix date, and the other as Java
>> Date??
>>
>> |    "|cancelled|":|true|,
>>     "|cancelledDate|":|"2015-02-03T00:34:19.654Z"|,
>>     "|lastvisit|":|1423180381094||
>>
>>
>> I call them one after the other?
>>
>> Thanks in advance!
>> ------------------------------------------------------------------------
>> *With best regards,*
>> Kiril Stankov
>>
>>


Re: Strange issue with dates

Posted by Stanley Iriele <si...@gmail.com>.
There is probably something off happening when parsing dates between what's
stored on disk in erlang what's sent back. Remember dates are not a thing
in JSON.

My advice would be to NEVER STORE DATES.  "New date().getTime()" and just
get the milliseconds...and when you want to use it use new
date(<milliseconds>). I've personally been bitten by date weirdness So its
best to work with something thats "interpret safe"
On Feb 5, 2015 4:09 PM, "Kiril Stankov" <ki...@open-net.biz> wrote:

> Hi,
>
> I have two update handlers:
>
> ||"|SetCancelled|":|"function(doc,req) {doc['cancelled']=true;
> doc['cancelledDate']=Date.now(); return [doc, 'ok'];}"|,
> "|SetLastVisit|":|"function(doc,req) {doc['lastvisit']=Date.now(); return
> [doc, 'ok'];}"
>
>
> |||
>
> How can it be one is writing the date as Unix date, and the other as Java
> Date??
>
> |    "|cancelled|":|true|,
>    "|cancelledDate|":|"2015-02-03T00:34:19.654Z"|,
>    "|lastvisit|":|1423180381094||
>
>
> I call them one after the other?
>
> Thanks in advance!
> ------------------------------------------------------------------------
> *With best regards,*
> Kiril Stankov
>
>

Strange issue with dates

Posted by Kiril Stankov <ki...@open-net.biz>.
Hi,

I have two update handlers:

||"|SetCancelled|":|"function(doc,req) {doc['cancelled']=true; doc['cancelledDate']=Date.now(); return [doc, 'ok'];}"|,
"|SetLastVisit|":|"function(doc,req) {doc['lastvisit']=Date.now(); return [doc, 'ok'];}"


|||

How can it be one is writing the date as Unix date, and the other as 
Java Date??

|    "|cancelled|":|true|,
    "|cancelledDate|":|"2015-02-03T00:34:19.654Z"|,
    "|lastvisit|":|1423180381094||


I call them one after the other?

Thanks in advance!
------------------------------------------------------------------------
*With best regards,*
Kiril Stankov


Re: Reducing on all emitted docs

Posted by Kiril Stankov <ki...@open-net.biz>.
Just found that... :)
Sorry, a bit more googling next time.
BTW, I use CouchDB for less than a month and I'm in love!
Thanks all!

------------------------------------------------------------------------
*With best regards,*
Kiril Stankov


            This Email disclaimer
            <http://open-net.biz/emailsignature.html> is integral part
            of this message.

On 2/5/2015 9:08 PM, Giovanni P wrote:
> running this with group=true will give you the sum per type, with
> group=false (or without any mention of "group") you'll get the total sum.
>
> On Thu, Feb 5, 2015 at 4:59 PM, Kiril Stankov <ki...@open-net.biz> wrote:
>
>> Hi,
>>
>> I want to get the sum of values from all results, produced by the map
>> function.
>> Something like this:
>>
>> |||  "|map|":|"function(doc) {\n  emit(doc.type, doc.total);\n}"|,
>>   "|reduce|":|"_sum"||||
>>
>>
>> Running this gives me sum per 'doc.type'.
>> I wonder if I can get the sum easily for all 'doc.total' values across all
>> documents, while still keeping the type as key for the map.
>>
>> Thanks in advance!
>> ------------------------------------------------------------------------
>> *With best regards,*
>> Kiril Stankov
>>
>> On 2/4/2015 2:37 AM, Ayhan Kesenci wrote:
>>
>>> I export a view with a curl command
>>>
>>> and the view looks like this in the map
>>>
>>> function(doc) {
>>> emit([doc.user.friends_count,
>>> doc.user.followers_count,doc.retweet_count,doc.text], doc.id_str);
>>> }
>>>
>>>
>>> is it possible to surround the for example doc.user.friends_count with
>>> quote signs, to have it like this with the usual comma between the quote
>>> signs?
>>>
>>>
>>> "doc.user.friends_count","
>>> doc.user.followers_count","doc.retweet_count","doc.text"
>>>
>>> thank you
>>>
>>> 2015-02-04 1:31 GMT+01:00 Ayhan Kesenci <a....@googlemail.com>:
>>>
>>>   I export a view with a curl command
>>>> and the view looks like this in the map
>>>>
>>>> function(doc) {
>>>> emit([doc.user.friends_count,
>>>> doc.user.followers_count,doc.retweet_count,doc.text], doc.id_str);
>>>> }
>>>>
>>>>
>>>> is it possible to surround the for example doc.user.friends_count with
>>>> quote signs, to have it like this with the usual comma between the quote
>>>> signs?
>>>>
>>>>
>>>> "doc.user.friends_count","
>>>> doc.user.followers_count","doc.retweet_count","doc.text"
>>>>
>>>>
>>>>


Re: Reducing on all emitted docs

Posted by Giovanni P <fi...@gmail.com>.
running this with group=true will give you the sum per type, with
group=false (or without any mention of "group") you'll get the total sum.

On Thu, Feb 5, 2015 at 4:59 PM, Kiril Stankov <ki...@open-net.biz> wrote:

> Hi,
>
> I want to get the sum of values from all results, produced by the map
> function.
> Something like this:
>
> |||  "|map|":|"function(doc) {\n  emit(doc.type, doc.total);\n}"|,
>  "|reduce|":|"_sum"||||
>
>
> Running this gives me sum per 'doc.type'.
> I wonder if I can get the sum easily for all 'doc.total' values across all
> documents, while still keeping the type as key for the map.
>
> Thanks in advance!
> ------------------------------------------------------------------------
> *With best regards,*
> Kiril Stankov
>
> On 2/4/2015 2:37 AM, Ayhan Kesenci wrote:
>
>> I export a view with a curl command
>>
>> and the view looks like this in the map
>>
>> function(doc) {
>> emit([doc.user.friends_count,
>> doc.user.followers_count,doc.retweet_count,doc.text], doc.id_str);
>> }
>>
>>
>> is it possible to surround the for example doc.user.friends_count with
>> quote signs, to have it like this with the usual comma between the quote
>> signs?
>>
>>
>> "doc.user.friends_count","
>> doc.user.followers_count","doc.retweet_count","doc.text"
>>
>> thank you
>>
>> 2015-02-04 1:31 GMT+01:00 Ayhan Kesenci <a....@googlemail.com>:
>>
>>  I export a view with a curl command
>>>
>>> and the view looks like this in the map
>>>
>>> function(doc) {
>>> emit([doc.user.friends_count,
>>> doc.user.followers_count,doc.retweet_count,doc.text], doc.id_str);
>>> }
>>>
>>>
>>> is it possible to surround the for example doc.user.friends_count with
>>> quote signs, to have it like this with the usual comma between the quote
>>> signs?
>>>
>>>
>>> "doc.user.friends_count","
>>> doc.user.followers_count","doc.retweet_count","doc.text"
>>>
>>>
>>>
>

Reducing on all emitted docs

Posted by Kiril Stankov <ki...@open-net.biz>.
Hi,

I want to get the sum of values from all results, produced by the map 
function.
Something like this:

|||  "|map|":|"function(doc) {\n  emit(doc.type, doc.total);\n}"|,
  "|reduce|":|"_sum"||||


Running this gives me sum per 'doc.type'.
I wonder if I can get the sum easily for all 'doc.total' values across 
all documents, while still keeping the type as key for the map.

Thanks in advance!
------------------------------------------------------------------------
*With best regards,*
Kiril Stankov

On 2/4/2015 2:37 AM, Ayhan Kesenci wrote:
> I export a view with a curl command
>
> and the view looks like this in the map
>
> function(doc) {
> emit([doc.user.friends_count,
> doc.user.followers_count,doc.retweet_count,doc.text], doc.id_str);
> }
>
>
> is it possible to surround the for example doc.user.friends_count with
> quote signs, to have it like this with the usual comma between the quote
> signs?
>
>
> "doc.user.friends_count","
> doc.user.followers_count","doc.retweet_count","doc.text"
>
> thank you
>
> 2015-02-04 1:31 GMT+01:00 Ayhan Kesenci <a....@googlemail.com>:
>
>> I export a view with a curl command
>>
>> and the view looks like this in the map
>>
>> function(doc) {
>> emit([doc.user.friends_count,
>> doc.user.followers_count,doc.retweet_count,doc.text], doc.id_str);
>> }
>>
>>
>> is it possible to surround the for example doc.user.friends_count with
>> quote signs, to have it like this with the usual comma between the quote
>> signs?
>>
>>
>> "doc.user.friends_count","
>> doc.user.followers_count","doc.retweet_count","doc.text"
>>
>>