回答編集履歴

2

追記

2018/08/10 00:25

投稿

umyu
umyu

スコア5846

test CHANGED
@@ -21,3 +21,29 @@
21
21
 
22
22
 
23
23
  大人の事情があると思いますが、INメモリで3GBのデータを扱うのはどうかと思います。。。
24
+
25
+
26
+
27
+ ---
28
+
29
+ ◇追記
30
+
31
+ > with open("need_data/raw_dict.json") as f:
32
+
33
+ > lines = f.readlines()
34
+
35
+ > でロードをするとlinesに配列が入り、
36
+
37
+
38
+
39
+ この記述が気になったので調べました。
40
+
41
+ [OSError: [Errno 22] when I try to .read() a json file](https://stackoverflow.com/questions/43723468/oserror-errno-22-when-i-try-to-read-a-json-file)
42
+
43
+ > It appears that this is some kind of bug that occurs when the file is too large (my file was ~10GB). Once I use split to break up the file by 200 k lines, the .read() error goes away. This is true even if the file is not in strict json format.
44
+
45
+
46
+
47
+ メモリ不足以外に不正なJSON形式でも`Invalid argument`の例外が発生するとのことです。
48
+
49
+ 不正確な回答申し訳ないです。

1

追記

2018/08/10 00:25

投稿

umyu
umyu

スコア5846

test CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  DOMじゃなくてSAXベースのjsonパーサーを使うとよいのでは。
6
6
 
7
- 「python json sax parser」でぐぐるとこれがHITしました。
7
+ 「python json sax parser」でググるとこれがHITしました。
8
8
 
9
9
  [json-streamer](https://github.com/kashifrazzaqui/json-streamer)
10
10
 
@@ -12,7 +12,7 @@
12
12
 
13
13
  仕様変更できるのであれば。
14
14
 
15
- 一度に処理するJSONデータを減らす。
15
+ ・処理対象のJSONのファイルサイズを減らす。
16
16
 
17
17
  ・JSON形式以外のデータ構造にする。
18
18
 
@@ -20,4 +20,4 @@
20
20
 
21
21
 
22
22
 
23
- あとINメモリで3GBのデータを扱うのはどうかと思います。。。
23
+ 大人の事情が思いますが、INメモリで3GBのデータを扱うのはどうかと思います。。。