I have three, near identical, nested arrays - ar1 and ar3 are owned by teams working on a project. ar2 is meant to be the "overview", gathering changes as they happen.
我有三个,几乎相同的嵌套数组 - ar1和ar3由项目团队拥有。 ar2意味着是“概述”,在它们发生时收集变化。
Each team can update only their part of the array. ar1 updates ar1[1] and ar1[2], ar3 updates ar3[3] and ar4[4].
每个团队只能更新他们的阵列部分。 ar1更新ar1 [1]和ar1 [2],ar3更新ar3 [3]和ar4 [4]。
I'd like ar2 to occasionally gather all of the changes, and push them out to both arrays (so each team is updated on the others progress)
我希望ar2偶尔收集所有的更改,并将它们推送到两个阵列(因此每个团队都会更新其他进度)
ar1 = [[id1, **red, apple,** foo, car]
[id2, **yellow, lemon,** rar, bar]
ar2 = [[id1, red, apple, boo, mario]
[id2, yellow, lemon, star, tim]]
ar1 = [[id1, blue, banana, **boo, mario**]
[id2, blue, tomato, **star, tim**]
The arrays end up on Google Sheets via Google scripts, if you'd like the context.
如果您想要上下文,那么阵列最终会通过Google脚本在Google表格上显示。
So my question - I've been working with for loops up until this point, to make sure everyone has new projects as they come in (and filtering out duplicates). But using nested for loops at this point would increase the workload by a lot - we're talking about thousands of projects.
所以我的问题 - 我一直在努力进行循环,直到这一点,以确保每个人都有新项目(并过滤掉重复项)。但是,此时使用嵌套for循环会大大增加工作量 - 我们谈论的是数千个项目。
Is there a faster way of working through this? Each project has a unique ID which may help.
有没有更快的方法来解决这个问题?每个项目都有一个唯一的ID,可能有所帮助。
2 个解决方案
#1
2
Use objects {}
instead of arrays for the data-management stage, and if the consumer (Google Sheets) requires the data to be in arrays, you can make a function that takes the objects and maps them to arrays of the format you require.
在数据管理阶段使用对象{}而不是数组,如果使用者(Google表格)要求数据在数组中,您可以创建一个函数来获取对象并将它们映射到您需要的格式的数组。
#2
0
I was shooting myself in the foot here by not learning databases - for anyone in the future coming here, this is the wrong way to go about it!
由于没有学习数据库,我在这里拍摄自己 - 对于未来的任何人来到这里,这是错误的方法!
(Plenty of 'for' statements will do the trick, comparing UIDs, but just getting a simple mySQL will help you much better).
(很多'for'语句可以解决这个问题,比较UID,但只是获得一个简单的mySQL会更好地帮助你)。
#1
2
Use objects {}
instead of arrays for the data-management stage, and if the consumer (Google Sheets) requires the data to be in arrays, you can make a function that takes the objects and maps them to arrays of the format you require.
在数据管理阶段使用对象{}而不是数组,如果使用者(Google表格)要求数据在数组中,您可以创建一个函数来获取对象并将它们映射到您需要的格式的数组。
#2
0
I was shooting myself in the foot here by not learning databases - for anyone in the future coming here, this is the wrong way to go about it!
由于没有学习数据库,我在这里拍摄自己 - 对于未来的任何人来到这里,这是错误的方法!
(Plenty of 'for' statements will do the trick, comparing UIDs, but just getting a simple mySQL will help you much better).
(很多'for'语句可以解决这个问题,比较UID,但只是获得一个简单的mySQL会更好地帮助你)。