Get a CSV or similiar from Array JSON and vice versa

Get help using Construct 3!

Post » Mon Oct 09, 2017 9:11 am

Hi there!

I've got a question:

I have an Array Object with the new Array Editor which stores all the dialogue of my game in a column for English and one for German Language. A variable switches which column is being called when dialogue is playing depending on the players language choice.

Now, since i'll have this edited and proofread when everything is set and done i wanted to export the .JSON file as something easy to externally edit like a .csv file. I found some online converters but i'm not quite sure how they'll work and if it will be able to convert the CSV back to JSON after editing is done... So my question is, how to best go about it or should i rather use rex's CSV Plugin from the beginning?

Is there a way to replace files in the File Menu of the Project window as well?

Thanks for your suggestions!

Joel
B
18
S
7
G
2
Posts: 113
Reputation: 2,210

Post » Mon Oct 09, 2017 8:51 pm

The simplest (recommended) way would be to use rex's plugin.

The manual way to do it would be to make a few events to export and import csv yourself.

You can use a loop for each element and the browser object's append to a file action, inserting commas and newlines in your loops where appropriate. To import it back in, you can parse the csv back in with tokenat. It is fairly straightforward, but probably not the easiest thing for a beginner.
Mistakes were made.
B
54
S
28
G
115
Posts: 1,705
Reputation: 65,083

Post » Mon Oct 09, 2017 11:45 pm

Thanks for your Reply @oosyrag

With C3 you got the new Array Editor which generates a JSON File in the Editor that you call upon and load into an Array via AJAX. So basically i'd just need to be able to edit the JSON as a CSV or just in a Spreadsheet Software like Google Spreadsheets and reupload it again but i'm not sure how to go about it without breaking the JSON.

Since the CSV Plugin was mainly for the convenience of editing Data in a Spreadsheet for me, with the new Array Editor i wouldn't really need it unless there's no way to get the Data out of C3 into a CSV or Excel and back again...

Maybe @Ashley has some advice? :) Would be very cool if we could export JSON to CSV or something similiar directly from Construct :D
B
18
S
7
G
2
Posts: 113
Reputation: 2,210

Post » Tue Oct 10, 2017 8:46 am

Scirra Founder
B
402
S
238
G
89
Posts: 24,644
Reputation: 196,095

Post » Tue Oct 10, 2017 4:43 pm

@Ashley

Sure but in the meantime how about this:

Would there be a way to make the Editors behave more like Excel or Google Spreadsheet in that i could select multiple cells? Now, i don't know if this would be technically possible but wouldn't it be relatively easy to implement now that you can copy paste from the Array Editor over to something like Excel or Google Spreads? Was just thinking haha ^^
B
18
S
7
G
2
Posts: 113
Reputation: 2,210

Post » Tue Oct 10, 2017 5:01 pm

Maybe, but reinventing Excel in one corner of C3 is a rabbit hole I'd rather avoid going down.
Scirra Founder
B
402
S
238
G
89
Posts: 24,644
Reputation: 196,095

Post » Tue Oct 10, 2017 11:52 pm

@Ashley Oh, comeon now, there might be untapped business opportunity here :P Seriously though, i just meant being able to copy cells from the Array Editor to an open Excel or similiar program but i guess that's not as easy to implement as it sounds :) No worries though, i might just use the CSV Plugin by Rex and all's good.

Thank you very much for taking the time to answer though! :)
B
18
S
7
G
2
Posts: 113
Reputation: 2,210

Post » Wed Oct 11, 2017 10:30 pm

Had some time to burn so I put this together if you're still interested - https://www.dropbox.com/s/of8uwu07mx2iq ... r.c3p?dl=0

Load a csv or json file from local drive to import into a C3 array, and you can export again to json or csv.

Basically does what rex's plugin does, without needing the plugin.

It only works with 2 dimensional arrays though.
Mistakes were made.
B
54
S
28
G
115
Posts: 1,705
Reputation: 65,083

Post » Thu Oct 12, 2017 11:10 am

@oosyrag : Wow, thank you so much this looks really helpful, i'll try it out when i get home tonight :)
B
18
S
7
G
2
Posts: 113
Reputation: 2,210

Post » Fri Oct 13, 2017 7:39 am

Allright, i tried it out @oosyrag and unfortunately i only get an Error Message when trying to load a file stating "Error: JSON is not a valid Construct array"... :?
B
18
S
7
G
2
Posts: 113
Reputation: 2,210

Next

Return to How do I...?

Who is online

Users browsing this forum: No registered users and 1 guest