Skip to content

Commit

Permalink
Add converter
Browse files Browse the repository at this point in the history
  • Loading branch information
yasuo-ozu committed Mar 22, 2017
1 parent 73b0da1 commit 40db14a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ cat dest/g_111973.txt | node app fetchClass - > dest/o_111973.json
```

## How to apply data
1. Open Admin console `https://example.com/admin`
1. Click `データの一括登録`
1. Register properties mapping
1. Upload the output file (json)
1. Run

```bash
find dest/o_* | xargs node converter >> dest/mongo_all.json
mongoimport --db coursecompass --collection classes --file mongo_all.json
```

## Important
- Only Admin users of Course Compass can apply some data.
Expand Down
20 changes: 20 additions & 0 deletions converter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
let fs = require('fs');
let i;
for (i = 2; i < process.argv.length; i++) {
let fname = process.argv[i];
fs.readFile(fname, 'utf8', function(err, text) {
if (err) {
console.log("error: " + fname);
} else {
let all = JSON.parse(text);

for(let record of all) {
process.stdout.write(JSON.stringify(record).replace(/\n/g, "") + "\n");

}

}
});


}

0 comments on commit 40db14a

Please sign in to comment.