Showing
1 changed file
with
37 additions
and
24 deletions
| ... | @@ -2,17 +2,7 @@ const config = require('./config') | ... | @@ -2,17 +2,7 @@ const config = require('./config') |
| 2 | const mongoose = require("mongoose"); | 2 | const mongoose = require("mongoose"); |
| 3 | const { range } = require("express/lib/request"); | 3 | const { range } = require("express/lib/request"); |
| 4 | const xlsx = require("xlsx"); | 4 | const xlsx = require("xlsx"); |
| 5 | - | 5 | +const fs = require('fs') |
| 6 | -fs.readdirSync(testFolder).forEach(file => { | ||
| 7 | - console.log(file); | ||
| 8 | -}); | ||
| 9 | - | ||
| 10 | -const excelFile = xlsx.readFile("./GuideLine/컴퓨터공학과 권장이수 가이드라인.xlsx"); | ||
| 11 | - | ||
| 12 | -const sheetName = excelFile.SheetNames[0]; | ||
| 13 | -const firstSheet = excelFile.Sheets[sheetName]; | ||
| 14 | -const jsonData = xlsx.utils.sheet_to_json(firstSheet); | ||
| 15 | - | ||
| 16 | var first_first = []; | 6 | var first_first = []; |
| 17 | var first_second = []; | 7 | var first_second = []; |
| 18 | var second_first = []; | 8 | var second_first = []; |
| ... | @@ -21,8 +11,8 @@ var third_first = []; | ... | @@ -21,8 +11,8 @@ var third_first = []; |
| 21 | var third_second = []; | 11 | var third_second = []; |
| 22 | var fourth_first = []; | 12 | var fourth_first = []; |
| 23 | var fourth_second = []; | 13 | var fourth_second = []; |
| 24 | -var new_list = []; | 14 | +var new_list = {}; |
| 25 | -function jason_to_arry() { | 15 | +function jason_to_arry(jsonData) { |
| 26 | for (var data in jsonData) { | 16 | for (var data in jsonData) { |
| 27 | first_first.push(jsonData[data]['1학년 1학기']); | 17 | first_first.push(jsonData[data]['1학년 1학기']); |
| 28 | first_second.push(jsonData[data]['1학년 2학기']); | 18 | first_second.push(jsonData[data]['1학년 2학기']); |
| ... | @@ -35,7 +25,8 @@ function jason_to_arry() { | ... | @@ -35,7 +25,8 @@ function jason_to_arry() { |
| 35 | } | 25 | } |
| 36 | } | 26 | } |
| 37 | // json -> array로 변경 | 27 | // json -> array로 변경 |
| 38 | -function remove_null() { | 28 | +function remove_null(major) { |
| 29 | + | ||
| 39 | first_first = first_first.filter(function (item) { | 30 | first_first = first_first.filter(function (item) { |
| 40 | return item !== null && item !== undefined && item !== ''; | 31 | return item !== null && item !== undefined && item !== ''; |
| 41 | }); | 32 | }); |
| ... | @@ -60,18 +51,40 @@ function remove_null() { | ... | @@ -60,18 +51,40 @@ function remove_null() { |
| 60 | fourth_second = fourth_second.filter(function (item) { | 51 | fourth_second = fourth_second.filter(function (item) { |
| 61 | return item !== null && item !== undefined && item !== ''; | 52 | return item !== null && item !== undefined && item !== ''; |
| 62 | }); | 53 | }); |
| 63 | - new_list.push(first_first); | 54 | + new_list[major]=[first_first,first_second,second_first,second_second,third_first,third_second,fourth_first,fourth_second] |
| 64 | - new_list.push(first_second) | 55 | + // new_list.push(first_first); |
| 65 | - new_list.push(second_first) | 56 | + // new_list.push(first_second) |
| 66 | - new_list.push(second_second); | 57 | + // new_list.push(second_first) |
| 67 | - new_list.push(third_first) | 58 | + // new_list.push(second_second); |
| 68 | - new_list.push(third_second); | 59 | + // new_list.push(third_first) |
| 69 | - new_list.push(fourth_first); | 60 | + // new_list.push(third_second); |
| 70 | - new_list.push(fourth_second); | 61 | + // new_list.push(fourth_first); |
| 62 | + // new_list.push(fourth_second); | ||
| 71 | } | 63 | } |
| 64 | + | ||
| 65 | +fs.readdirSync("./GuideLine").forEach(file => { | ||
| 66 | + // console.log(file); | ||
| 67 | + var major=file.split(' ')[0] | ||
| 68 | + console.log(major) | ||
| 69 | + const excelFile = xlsx.readFile(`./GuideLine/${file}`) | ||
| 70 | + const sheetName = excelFile.SheetNames[0]; | ||
| 71 | + const firstSheet = excelFile.Sheets[sheetName]; | ||
| 72 | + const jsonData = xlsx.utils.sheet_to_json(firstSheet) | ||
| 73 | + jason_to_arry(jsonData) | ||
| 74 | + remove_null(major) | ||
| 75 | + first_first = []; | ||
| 76 | + first_second = []; | ||
| 77 | + second_first = []; | ||
| 78 | + second_second = []; | ||
| 79 | + third_first = []; | ||
| 80 | + third_second = []; | ||
| 81 | + fourth_first = []; | ||
| 82 | + fourth_second = []; | ||
| 83 | +}); | ||
| 84 | +console.log(new_list['']) | ||
| 85 | +// const excelFile = xlsx.readFile("./GuideLine/컴퓨터공학과 권장이수 가이드라인.xlsx"); | ||
| 72 | // null 값 제거 | 86 | // null 값 제거 |
| 73 | -jason_to_arry() | 87 | + |
| 74 | -remove_null() | ||
| 75 | 88 | ||
| 76 | 89 | ||
| 77 | const connect = mongoose.connect(config.url, | 90 | const connect = mongoose.connect(config.url, | ... | ... |
-
Please register or login to post a comment