亲爱的Stackoverflow社区,
我有一个34 GB的json文件,里面有很多数据.我试图通过使用mongoimport --file file.json导入到我的mongodb中 - 但它失败了,因为文件太大而且扔了一个你知道的内存系统抛出错误.是否可以使用PHP代码使用游标迭代文件?我对此没有经验,有人告诉我这是可能的.我想知道文件是如何构建的,但我不知道如何查看它的示例数组.从源代码我可以得到一个示例数组:
{
"_id": ObjectId("53b29644aafd413977b23b7e"),
"summonerId": NumberLong(24570940),
"region": "euw",
"updatedAt": NumberLong(1404212804),
"season": NumberLong(4),
"stats": {
"110": {
"totalSessionsPlayed": NumberLong(3),
"totalSessionsLost": NumberLong(2),
"totalSessionsWon": NumberLong(1),
"totalChampionKills": NumberLong(34),
"totalDamageDealt": NumberLong(415051),
"totalDamageTaken": NumberLong(63237),
"mostChampionKillsPerSession": NumberLong(12),
"totalMinionKills": NumberLong(538),
"totalDoubleKills": NumberLong(5),
"totalTripleKills": NumberLong(1),
"totalDeathsPerSession": NumberLong(18),
"totalGoldEarned": NumberLong(40977),
"totalTurretsKilled": NumberLong(6),
"totalPhysicalDamageDealt": NumberLong(381668),
"totalMagicDamageDealt": NumberLong(31340),
"totalAssists": NumberLong(25),
"maxChampionsKilled": NumberLong(12),
"maxNumDeaths": NumberLong(10)
}
}
}
Run Code Online (Sandbox Code Playgroud)
字段统计包含更多数组,110只是一个示例.如何迭代这个大文件或如何将其导入我的mongodb?例如; 我想要回忆summonerid,championid(在这种情况下是110),totalSessionsPlayed.它必须尽可能多地重新循环,直到没有为这个特殊的召唤者留下任何冠军.
再一次......一个召唤者ID有一个在他的职业生涯中一直在玩的冠军名单.冠军指的是(在这个例子中)110.每一个召唤者都可以包含多个冠军,我希望拥有所有冠军,召唤者总共玩过多少次冠军(全部激情).