+ Reply to Thread
Results 1 to 12 of 12

Pulling json or csv data from a url

  1. #1
    Registered User
    Join Date
    09-04-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    20

    Pulling json or csv data from a url

    I don't even know if this is possible, but I would like to try to make this work. I want to create a function in a spreadsheet that will pull information from a website that contains a json or csv file with the information it needs. I have a java code that does this already. But as far as I can tell, I can not implement this into VBA. However if there is anybody who understands both codes and can possibly translate it that would be awesome. So, here is the Java code:

    Please Login or Register  to view this content.
    Thank you

  2. #2
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Pulling json or csv data from a url

    Can you post the json?

  3. #3
    Registered User
    Join Date
    09-04-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: Pulling json or csv data from a url

    What is it that you need? The json file or the link to it?

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Pulling json or csv data from a url

    Hello Versial,

    I think Kyle was asking for the json file. But to be safe, why not post both the file and the link.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  5. #5
    Registered User
    Join Date
    09-04-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: Pulling json or csv data from a url

    The reason I ask is because the file will vary according to what ID number you are looking for. This holds true for the url as well.

  6. #6
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Pulling json or csv data from a url

    Thanks Leith, yes, I was asking for the json string, your code suggests the data should be very easy to get, but there's no built in json parser in excel vba, so you'd normally use string manipulation to get the data you want, but to give you a solution for that, I'd need to see the data.

    Edit: true, but the structure of the json wont

  7. #7
    Registered User
    Join Date
    09-04-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: Pulling json or csv data from a url

    Okay I thought it might be the format you where interested in a link to an item in the json would be http://www.gw2spidy.com/api/v0.9/json/item/76

  8. #8
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Pulling json or csv data from a url

    Does that java actually work for the link you posted? I'd guess not since there's no "price" in that json string. Which data is it specifically that you're after?

  9. #9
    Registered User
    Join Date
    09-04-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: Pulling json or csv data from a url

    The data was adjusted from me trying to mess with it. The info i am going to pull would be "name", "min_sale_unit_price", "max_offer_unit_price", "offer_availability", "sale_availability". So if you plug those in, yes the java works. I kind of have an idea with my limited understanding of VBA how it would work. There are a few hurdles I haven't been able to cross yet.

    Please Login or Register  to view this content.
    The items in red get kicked back because I believe that is the specific to java code and I haven't found anything to use in VBA to replace it with.
    Last edited by Versial; 12-09-2012 at 04:10 PM.

  10. #10
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Pulling json or csv data from a url

    Based on the json structure you provided:
    Please Login or Register  to view this content.
    I've included item as string since there's a possibility that all the items aren't numbers and it doesn't affect the process.

  11. #11
    Registered User
    Join Date
    09-04-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: Pulling json or csv data from a url

    Works like a charm, thank you very much. One other question, when can I get these items to update? Will it do it upon open or can I put it on a time schedule?

  12. #12
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Pulling json or csv data from a url

    I think you need to give a bit more detail on your project, since I have no idea how you are using the code, it's a little difficult to comment

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1