How do I import data from a csv/json file?

0 favourites
  • 7 posts
From the Asset Store
Convert multiple Excel files into JSON files and import them into construct3.
  • Hi all,

    Does anyone have a .capx file which shows how to import data from a file?

    I've fiddled around with this for hours without success, including reading tutorials and forum posts and trying out plugins.

    What I have managed is to hack together a "json" format in Excel and copy/paste this in using the "Load from json string" into an array.

    I can create json and text files and bring them into the project. But loading from these files into an array just won't work for me.

    So if anyone can help with a .capx showing where I'm going wrong, I'd appreciate it!

    Thanks,

    Mike

  • bump

    Can nobody help with this?

  • Could I see your .capx ? Maybe it's just a little error from you ?

  • condition System -> on start of layout

    action AJAX -> request project file tag

    You need to manually import the file into files folder. It should be a text file that is like....{"c2array":true,"size":[3,3,1],"data":[[["Shovel"],["Chisels"],["Pickaxe"]],[["2.75"],["0.75"],["2.25"]],[[3],[0],[4]]}.

    Condition AJAX -> on completed tag

    Action Array -> Load AJAX.lastData

    That's how I did it in this capx:

    dl.dropbox.com/u/27144902/inventory.capx

    Although, I'm only able to get this to work by manualy loading file. I believe if you want to dynamically import or export JSON you'll need to experiment with AJAX request and post.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Yep. An error by me for sure. I'm good at those. My capx only has the copy/paste version in though.

    Jase5z This is great! Thanks ;) I didn't have the "Load from json string ajax.lastdata" business working.

    By the way, in this thread PePPo is having problems using Ajax with cocoon. So is it better to avoid using ajax? (I want to export to IOS) What do you think?

    scirra.com/forum/topic62892.html

  • curious Mike "problems using Ajax with cocoon", I can't answer this. I just used the tool as explain in the manual.

  • doesn't make sense? so how do u load JSON variable/data in and access it by key/value?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)