Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RMONGO with streaming data #18

Open
louisdv1 opened this issue May 1, 2013 · 6 comments
Open

RMONGO with streaming data #18

louisdv1 opened this issue May 1, 2013 · 6 comments

Comments

@louisdv1
Copy link

louisdv1 commented May 1, 2013

Hi , I am pulling data out of an API with R and it seems that the insert to mongodb keeps failing?
This is the message I am having:
Error in .jcall(rmongo.object@javaMongo, "S", "dbInsertDocument", collection, :
com.mongodb.util.JSONParseException:

@tc
Copy link
Owner

tc commented May 1, 2013

What query command are you running? what does your mongo collection look like?

@louisdv1
Copy link
Author

louisdv1 commented May 1, 2013

Hi Tommy and thank you for the fast response.
I am pulling data out of stocktwits and pushing it to mongodb.
Sometimes I have a parsing problem but the most problematic is that the
json feed representing several messages seem to be bundled up together so
that mongo only recognizes one message per call .
Here is my code

for (i in 1:5) {

result=tryCatch({getURL(url="
https://api.stocktwits.com/api/2/streams/symbol/msf.json",cainfo =
"cacert.pem")},error=function(e){})

if (length(result)>0)  dbInsertDocument(mongo, "stocktwits7", z)

Sys.sleep(10)

}

Thank you very much
On 1 May 2013 17:26, "Tommy Chheng" [email protected] wrote:

What query command are you running? what does your mongo collection look
like?


Reply to this email directly or view it on GitHubhttps://github.com//issues/18#issuecomment-17290176
.

@tc
Copy link
Owner

tc commented May 1, 2013

What is z in dbInsertDocument(mongo, "stocktwits7", z)? It looks like an unreferenced variable.

@tc
Copy link
Owner

tc commented May 1, 2013

You can also use rjson to extract the messages array out of the url
response.

On Wed, May 1, 2013 at 11:01 AM, louisdv1 [email protected] wrote:

Hi Tommy and thank you for the fast response.
I am pulling data out of stocktwits and pushing it to mongodb.
Sometimes I have a parsing problem but the most problematic is that the
json feed representing several messages seem to be bundled up together so
that mongo only recognizes one message per call .
Here is my code

for (i in 1:5) {

result=tryCatch({getURL(url="
https://api.stocktwits.com/api/2/streams/symbol/msf.json",cainfo =
"cacert.pem")},error=function(e){})

if (length(result)>0) dbInsertDocument(mongo, "stocktwits7", z)

Sys.sleep(10)

}

Thank you very much
On 1 May 2013 17:26, "Tommy Chheng" [email protected] wrote:

What query command are you running? what does your mongo collection look
like?


Reply to this email directly or view it on GitHub<
https://github.com/tc/RMongo/issues/18#issuecomment-17290176>
.


Reply to this email directly or view it on GitHubhttps://github.com//issues/18#issuecomment-17296054
.

Tommy Chheng

@louisdv1
Copy link
Author

louisdv1 commented May 1, 2013

Stocktwits is just the name of tge collection and z is a json response
fetched by rcurl
On 1 May 2013 20:39, "Tommy Chheng" [email protected] wrote:

You can also use rjson to extract the messages array out of the url
response.

On Wed, May 1, 2013 at 11:01 AM, louisdv1 [email protected]
wrote:

Hi Tommy and thank you for the fast response.
I am pulling data out of stocktwits and pushing it to mongodb.
Sometimes I have a parsing problem but the most problematic is that the
json feed representing several messages seem to be bundled up together
so
that mongo only recognizes one message per call .
Here is my code

for (i in 1:5) {

result=tryCatch({getURL(url="
https://api.stocktwits.com/api/2/streams/symbol/msf.json",cainfo =
"cacert.pem")},error=function(e){})

if (length(result)>0) dbInsertDocument(mongo, "stocktwits7", z)

Sys.sleep(10)

}

Thank you very much
On 1 May 2013 17:26, "Tommy Chheng" [email protected] wrote:

What query command are you running? what does your mongo collection
look
like?


Reply to this email directly or view it on GitHub<
https://github.com/tc/RMongo/issues/18#issuecomment-17290176>
.


Reply to this email directly or view it on GitHub<
https://github.com/tc/RMongo/issues/18#issuecomment-17296054>
.

Tommy Chheng


Reply to this email directly or view it on GitHubhttps://github.com//issues/18#issuecomment-17301621
.

@tc
Copy link
Owner

tc commented May 1, 2013

Try printing out the z variable to see if it's malformed. That could be
the reason why it's not inserting correctly.

On Wed, May 1, 2013 at 12:42 PM, louisdv1 [email protected] wrote:

Stocktwits is just the name of tge collection and z is a json response
fetched by rcurl
On 1 May 2013 20:39, "Tommy Chheng" [email protected] wrote:

You can also use rjson to extract the messages array out of the url
response.

On Wed, May 1, 2013 at 11:01 AM, louisdv1 [email protected]
wrote:

Hi Tommy and thank you for the fast response.
I am pulling data out of stocktwits and pushing it to mongodb.
Sometimes I have a parsing problem but the most problematic is that
the
json feed representing several messages seem to be bundled up together
so
that mongo only recognizes one message per call .
Here is my code

for (i in 1:5) {

result=tryCatch({getURL(url="
https://api.stocktwits.com/api/2/streams/symbol/msf.json",cainfo =
"cacert.pem")},error=function(e){})

if (length(result)>0) dbInsertDocument(mongo, "stocktwits7", z)

Sys.sleep(10)

}

Thank you very much
On 1 May 2013 17:26, "Tommy Chheng" [email protected] wrote:

What query command are you running? what does your mongo collection
look
like?


Reply to this email directly or view it on GitHub<
https://github.com/tc/RMongo/issues/18#issuecomment-17290176>
.


Reply to this email directly or view it on GitHub<
https://github.com/tc/RMongo/issues/18#issuecomment-17296054>
.

Tommy Chheng


Reply to this email directly or view it on GitHub<
https://github.com/tc/RMongo/issues/18#issuecomment-17301621>
.


Reply to this email directly or view it on GitHubhttps://github.com//issues/18#issuecomment-17301832
.

Tommy Chheng

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants