-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Lisenser og lenker til datasett på Geonorge (#504)
* Lisenser og lenker til datasett på Geonorge - Kloner nå data fra https://github.com/Artsdatabanken/nin-data - Leser CSV direkte - Mapper dynamisk kolonner fra CSV-fil. Nye kolonner resulterer i nye nøkler * Create the git checkout directory if necessary * Les fra nin-data git checkout dir * Kan ikke spesifisere checkout path uten trøbbel, skipper
- Loading branch information
1 parent
8f769c4
commit 2deeef8
Showing
8 changed files
with
128 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,5 @@ build/ | |
node_modules/ | ||
.vscode/ | ||
kildedata/raster_index.json | ||
log/ | ||
log/ | ||
nin-data/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
const parse = require("csv-parse/lib/sync") | ||
const fs = require("fs") | ||
var JSONStream = require("JSONStream") | ||
|
||
function les(csvFilePath) { | ||
const input = fs.readFileSync(csvFilePath) | ||
const records = parse(input, { | ||
columns: true | ||
}) | ||
return records | ||
} | ||
|
||
module.exports = { les } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
const execSync = require("child_process").execSync | ||
const fs = require("fs") | ||
|
||
function git(cmd, args = "") { | ||
execSync("git " + cmd + " " + args) | ||
} | ||
|
||
function clone(url, destFolder) { | ||
if (fs.existsSync(destFolder)) pull(destFolder) | ||
// only latest version | ||
else { | ||
fs.mkdirSync(destFolder) | ||
git(`clone --depth=1 ${url}`) | ||
} | ||
} | ||
|
||
function pull(destFolder) { | ||
git(`-C ${destFolder} pull`) | ||
} | ||
|
||
module.exports = { clone } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const config = require("../../config") | ||
const git = require("../../lib/git") | ||
|
||
// Download "Natur i Norge" data kildedata | ||
git.clone("https://github.com/Artsdatabanken/nin-data.git", "nin-data") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters