Skip to content

Commit 8a935fd

Browse files
author
Pieter Colpaert
committed
Fix #10
1 parent 6b0b313 commit 8a935fd

2 files changed

Lines changed: 11 additions & 6 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ In this case, you can install it globally using `npm install -g gtfs-csv2rdf`
1717
# First argument: path to gtfs
1818
# Second argument: the version of the feed
1919
# Third argument: the base URI
20-
# Forth argument (optional): the requested format (turtle or jsonld)
20+
# Forth argument (optional): the requested format (turtle, ntriples or jsonld)
2121
gtfs-csv2rdf path-to-gtfs.zip 0.1 http://data.gtfs.org/ turtle > gtfsintriples.ttl
2222
```
2323
### As a nodejs library

gtfs-csv2rdf

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ if (process.argv[4]) {
3939
}
4040

4141
var type = "turtle";
42-
if (process.argv[5] && process.argv[5] === 'jsonld') {
43-
type = "jsonld";
42+
if (process.argv[5] && ['jsonld','turtle','ntriples'].indexOf(process.argv[5]) !== -1 ) {
43+
type = process.argv[5];
4444
}
4545

4646
if (!fs.existsSync(path)) {
@@ -67,11 +67,16 @@ var prefixes = { 'gtfs': 'http://vocab.gtfs.org/terms#',
6767
'schema' : "http://schema.org/",
6868
'dcat' : 'http://www.w3.org/ns/dcat#'};
6969

70-
var streamWriter = new N3.StreamWriter(prefixes);
70+
var streamWriter;
71+
7172
if (type === "jsonld") {
72-
streamWriter = new toJsonLD();
73+
streamWriter = (new toJsonLD()).pipe(stringify);
74+
} else if (type === "ntriples") {
75+
streamWriter = new N3.StreamWriter({format: 'N-Triples' });
76+
} else {
77+
streamWriter = new N3.StreamWriter({prefixes: prefixes});
7378
}
74-
streamWriter.pipe(stringify).pipe(process.stdout);
79+
streamWriter.pipe(process.stdout);
7580

7681
mapper(fs.createReadStream(path), streamWriter, {
7782
feedname: feedname,

0 commit comments

Comments
 (0)