Skip to content

Instantly share code, notes, and snippets.

@phochste
Created April 30, 2015 08:05
Show Gist options
  • Save phochste/fac239564a38f8c2eb8a to your computer and use it in GitHub Desktop.
Save phochste/fac239564a38f8c2eb8a to your computer and use it in GitHub Desktop.
#!/usr/bin/env node
/*
* Install: npm install n3
* Usage: cat gigantic.ttl | tutle2ntriples
* Usage: tutle2ntriples gigantic.ttl
*
* See also: https://github.com/RubenVerborgh/N3.js
*/
var file = undefined;
if (process.argv.length == 2) {
file = '/dev/stdin';
}
else {
file = process.argv[2];
}
var N3 = require('n3');
var fs = require('fs');
var streamParser = new N3.StreamParser(),
inputStream = fs.createReadStream(file),
streamWriter = new N3.StreamWriter({ format: 'N-Triples' });
inputStream.pipe(streamParser);
streamParser.pipe(streamWriter);
streamWriter.pipe(process.stdout);
@phochste
Copy link
Author

hehehe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment