-
Notifications
You must be signed in to change notification settings - Fork 0
/
makeCreated.js
77 lines (67 loc) · 2 KB
/
makeCreated.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import { CSV } from "https://js.sabae.cc/CSV.js";
// https://www.houjin-bangou.nta.go.jp/download/sabun/
export const filterCreated = (d) => d.process == "新規" && d.correct == 0;
export const filterTerminated = (d) => {
return (d.process == "登記記録の閉鎖等" || d.process == "商号の登記の抹消" || d.process == "削除") &&
d.correct == 0;
};
export const makeCreated = async (date) => {
const csv = await CSV.fetch("data/diff_" + date + ".csv");
console.log(csv.length, csv[0].length);
const houjin = CSV.toJSON(await CSV.fetch("./houjin.csv"));
const head = houjin.map((d) => d.name);
csv.unshift(head);
const data = CSV.toJSON(csv);
//console.log(data[0]);
// enum
const enums = houjin.filter((d) => d.type == "enum").map((d) => {
return { name: d.name };
});
for (const e of enums) {
console.log(e);
e.data = CSV.toJSON(await CSV.fetch(e.name + ".csv"));
}
data.forEach((d) => {
enums.forEach((e) => {
if (d[e.name]) {
const v = e.data.find((e1) => e1.name == d[e.name]);
d[e.name] = v.label;
}
});
});
//console.log(data[0]);
/* // process.csv
name,label
01,新規
11,商号又は名称の変更
12,国内所在地の変更
13,国外所在地の変更
21,登記記録の閉鎖等
22,登記記録の復活等
71,吸収合併 // 存続会社が記載されている
72,吸収合併無効
81,商号の登記の抹消
99,削除
*/
// filter
const data2 = data.filter(filterCreated);
await Deno.writeTextFile(
"data/diff_" + date + "_created.csv",
CSV.stringify(data2),
);
const data3 = data.filter(filterTerminated);
await Deno.writeTextFile(
"data/diff_" + date + "_terminated.csv",
CSV.stringify(data3),
);
};
if (Deno.mainModule.endsWith("/makeCreated.js")) {
//const date = "20210908";
//const date = "20210909";
const date = "20210910";
await makeCreated(date);
for (let i = 6; i < 10; i++) {
const date = "2021090" + i;
await makeCreated(date);
}
}