string concatenation is not working as expectred for URL call in PYTHON -


i trying extract dividend data , having success. want not have required string generated automatically off of list of ticker symbols (ibm, msft, ge . . .etc).

the below python code works:

import quandl divdf=quandl.get("sec/div_ibm", authtoken="w3p77lrwvfzvffl9sib4")  divdf.head()  out[1]: date        dividend     1962-02-06  0.00100 1962-05-08  0.00100 1962-08-07  0.00100 1962-11-05  0.00100 1963-02-05  0.00133 

but when try create string inside get() not. here code have tried:

parta=('"sec/div_') symbol=('ibm"') authtoken='"w3p77lrwvfzvffl9sib4"' totalgrab = parta + symbol + ", authtoken=" + authtoken 

when print totalgrab looks if work because appears identical original string . unfortunately not work.

in [19]:  print(totalgrab) "sec/div_ibm", authtoken="w3p77lrwvfzvffl9sib4"  try1=quandl.get(totalgrab) 

gives me error:

errordownloading: error downloading! http error 400: bad_request 

i tried well, no luck:

divdf=quandl.get(parta + symbol, authtoken="w3p77lrwvfzvffl9sib4") 

any thoughts on fix?

thanks attention this.

john

in code works:

divdf=quandl.get("sec/div_ibm", authtoken="w3p77lrwvfzvffl9sib4") 

the get() method takes 2 arguments: "sec/div_ibm" , authtoken.

in example not work, passing in single argument, string.

here's example demonstrate doing:

a = 2 b = 3 sum(a,b) ## works  c = "{0}, {1}".format(a,b) ## generates string "2,3" sum(c) ## won't work.  

Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -