-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnode.js
More file actions
36 lines (33 loc) · 1009 Bytes
/
Copy pathnode.js
File metadata and controls
36 lines (33 loc) · 1009 Bytes
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
const ExcelJS = require("exceljs");
const shapefile = require("shapefile");
const turf = require("turf");
const encoding = require("encoding");
const RECORDS = [];
var fs = require("fs"); //文件模块
var path = require("path"); //系统路径模块
(async () => {
// 读取excel
const workbook = new ExcelJS.Workbook();
await workbook.xlsx.readFile(__dirname + "/合并.xlsx");
const sheet = workbook.worksheets[0];
let field = [];
sheet.eachRow(function (row, rowNumber) {
if (rowNumber == 1) {
field = row.values;
} else {
let user = {};
row.values.forEach((item, index) => {
user[field[index]] = item;
});
RECORDS.push(user);
}
});
var file = path.join(__dirname, "/json/ent_data.json");
var content = JSON.stringify(RECORDS);
fs.writeFile(file, content, function (err) {
if (err) {
return console.log(err);
}
console.log("文件创建成功,地址:" + file);
});
})();