street2coordinates POST method

153 views
Skip to first unread message

Lance Crumbliss

unread,
Mar 28, 2013, 3:13:20 PM3/28/13
to dstk-...@googlegroups.com
Can someone tell me the format the body needs to be in when sending a batch of addresses to geocode using POST?  I've tried:

('400 W BACHERT ST, LAFAYETTE, LA'
,'100 GIRARD PARK CL, LAFAYETTE, LA'
,'200 MCKINLEY ST, LAFAYETTE, LA'
,'1525 N UNIVERSITY AV, LAFAYETTE, LA'
,'6002 JOHNSTON ST, LAFAYETTE, LA'
,'1700 N UNIVERSITY AV, LAFAYETTE, LA'
,'4404 JOHNSTON ST, LAFAYETTE, LA'
,'1251 COOLIDGE ST, LAFAYETTE, LA'
,'1300 W UNIVERSITY AV, LAFAYETTE, LA')

and

'400 W BACHERT ST, LAFAYETTE, LA'
,'100 GIRARD PARK CL, LAFAYETTE, LA'
,'200 MCKINLEY ST, LAFAYETTE, LA'
,'1525 N UNIVERSITY AV, LAFAYETTE, LA'
,'6002 JOHNSTON ST, LAFAYETTE, LA'
,'1700 N UNIVERSITY AV, LAFAYETTE, LA'
,'4404 JOHNSTON ST, LAFAYETTE, LA'
,'1251 COOLIDGE ST, LAFAYETTE, LA'
,'1300 W UNIVERSITY AV, LAFAYETTE, LA'

and

('400 W BACHERT ST, LAFAYETTE, LA'
'100 GIRARD PARK CL, LAFAYETTE, LA'
'200 MCKINLEY ST, LAFAYETTE, LA'
'1525 N UNIVERSITY AV, LAFAYETTE, LA'
'6002 JOHNSTON ST, LAFAYETTE, LA'
'1700 N UNIVERSITY AV, LAFAYETTE, LA'
'4404 JOHNSTON ST, LAFAYETTE, LA'
'1251 COOLIDGE ST, LAFAYETTE, LA'
'1300 W UNIVERSITY AV, LAFAYETTE, LA')

and
 
'400 W BACHERT ST, LAFAYETTE, LA'
'100 GIRARD PARK CL, LAFAYETTE, LA'
'200 MCKINLEY ST, LAFAYETTE, LA'
'1525 N UNIVERSITY AV, LAFAYETTE, LA'
'6002 JOHNSTON ST, LAFAYETTE, LA'
'1700 N UNIVERSITY AV, LAFAYETTE, LA'
'4404 JOHNSTON ST, LAFAYETTE, LA'
'1251 COOLIDGE ST, LAFAYETTE, LA'
'1300 W UNIVERSITY AV, LAFAYETTE, LA'

but all that happens is returned is basically an echo:

{
  "'400 W BACHERT ST, LAFAYETTE, LA'\r\n'100 GIRARD PARK CL, LAFAYETTE, LA'\r\n'200 MCKINLEY ST, LAFAYETTE, LA'\r\n'1525 N UNIVERSITY AV, LAFAYETTE, LA'\r\n'6002 JOHNSTON ST, LAFAYETTE, LA'\r\n'1700 N UNIVERSITY AV, LAFAYETTE, LA'\r\n'4404 JOHNSTON ST, LAFAYETTE, LA'\r\n'1251 COOLIDGE ST, LAFAYETTE, LA'\r\n'1300 W UNIVERSITY AV, LAFAYETTE, LA'": null

Pete Warden

unread,
Mar 29, 2013, 5:18:07 PM3/29/13
to dstk-...@googlegroups.com
Sorry about that Lance! You actually need to use JSON-style arrays, just like the first example but with square brackets instead of round ones. I've updated the docs to give a better description:
and here's how you do it with curl from the command line:

curl -X POST --data '["2543 Graystone Place, Simi Valley, CA 93065", "400 Duboce Ave, San Francisco, CA 94114"]' 'http://www.datasciencetoolkit.org/street2coordinates'

Does that help?

cheers,

           Pete

--
You received this message because you are subscribed to the Google Groups "dstk-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dstk-users+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Jetpac

Lance Crumbliss

unread,
Mar 29, 2013, 5:59:25 PM3/29/13
to dstk-...@googlegroups.com, pe...@jetpac.com
that's it!  i thought i had tried it previously, but i think i was using single quotes instead of double quotes.  Thanks!

Lance

flmar...@gmail.com

unread,
May 28, 2014, 11:15:11 AM5/28/14
to dstk-...@googlegroups.com, pe...@jetpac.com
I know this isn't strictly related to DSTK, but it's related to using it. How can I take address data from a file--I have about 128k records--and pass them to the body of the request?

Thanks!

Jay

sophia parafina

unread,
May 28, 2014, 2:09:14 PM5/28/14
to dstk-...@googlegroups.com
Something like this?

while read a; do curl -X POST --data '[$a]' 'http://www.datasciencetoolkit.org/street2coordinates'; done < addresses.txt 

sophia


For more options, visit https://groups.google.com/d/optout.

flmar...@gmail.com

unread,
May 29, 2014, 10:41:33 AM5/29/14
to dstk-...@googlegroups.com
Hi Sophia,

Thanks for the response! I ended up using the following.

curl -o st2coord.json -X POST --data "[`cat addressarray.txt`]" 'http://www.datasciencetoolkit.org/street2coordinates'

That worked on a small sample of addresses. However, with my full set, it doesn't work.

-bash: /usr/bin/curl: Argument list too long

I guess I'll have to parse the list an iterate over the pieces.

Thanks,
Jay

Pete Warden

unread,
May 29, 2014, 11:25:13 AM5/29/14
to dstk-...@googlegroups.com
It sounds like you're close, I'd recommend trying curl's file options for data:
"If you start the data with the letter @, the rest should be a file name to read the data from, or - if you want curl to read the data from stdin. Multiple files can also be specified. Posting data from a file named 'foobar' would thus be done with --data @foobar. When --data is told to read from a file like that, carriage returns and newlines will be stripped out."

Because you need to add the square brackets, you might want to pipe it in and use stdin, or just alter the file itself to add the brackets.
--
Check out Jetpac City Guides iPhone app - Just launched!

CTO Jetpac
Follow me on twitter @petewarden

flmar...@gmail.com

unread,
May 30, 2014, 11:37:55 AM5/30/14
to dstk-...@googlegroups.com, pe...@jetpac.com
Pete,

Thank you! The @ did the trick. This is so great!

I appreciate it.

Jay
Reply all
Reply to author
Forward
0 new messages