Reputation: 149
I have a very very large array of 44,000+ objects in a javascript file.
My problem is editing the file is absolutely terrible (especially if I must move each object 1 value in the array).
I've tried a csv file, but I am unable to have the text be my objects. I've considered XML and JSON but I don't see it fixing my editing problems.
I'm hoping for a javascript editor that handles 2d arrays like a table, or essentially anything that will create the array of objects and allow me to edit similarly to a table.
Thanks
Upvotes: 0
Views: 1300
Reputation: 150080
OK, first of all: what the what? 44,000 objects hardcoded in your source file? Why do you even have 44,000 objects anyway, and can't you generate them somehow?
Anyway...
Assuming I understand your requirement correctly, my suggestion to solve your editing problem but still produce a standard JS script file is to use an Excel spreadsheet to do your editing, saving your source data in standard Excel format, and write an Excel macro (VBA) to produce the desired JS file output at the press of a button, a bit like pressing the compile button in an IDE. Seriously. It sounds like you want a nice visual editor that can move things around within your array, shift cells up on delete, all the kind of things that Excel is good at. The VBA macro you'd need to take the data from the spreadsheet and output it as a JS file with a valid JavaScript array declaration would be trivial, no more than 20 or 30 lines of code, basically a simple nested for loop ought to do it with some initialisation to open a file for writing, etc.
Bearing in mind JavaScript doesn't have multidimensional arrays I'm assuming you want an array of arrays where each child array is the same length and contains objects, and that your desired output JS file is something like this (except much bigger):
var myObjectArray = [
[ {id:1}, {id:2}, {id:3}, {id:4} ],
[ {id:5}, {id:6}, {id:7}, {id:8} ],
[ {id:9}, {id:10},{id:11},{id:12} ],
[ {id:13},{id:14},{id:15},{id:16} ]
];
It's easy to produce something like that from Excel.
Upvotes: 1