Browse files

start implementing more csv related gut parsers

  • Loading branch information...
1 parent f784d9e commit 579e0fa98198c8f4df8e9f7b2b2136edd41118ef @maxogden maxogden committed Nov 13, 2011
View
2 README.md
@@ -33,6 +33,6 @@ My server (cat-information.com) will receive the following HTTP POST:
{"headers":[{"name":"name"},{"name":"appearance"}],"rows":[{"name":"chewbacca","appearance":"hairy"},{"name":"bill","appearance":"nonplussed"},{"name":"bubbles","appearance":"relaxed"}]}
-currently only a CSV gut service is implemented, but you are encouraged to fork and add your own simple gut servers for common open data transformation formats. some useful ones might include:
+currently only a CSV and JSON related gut servicesare implemented, but you are encouraged to fork and add your own simple gut servers for common open data transformation formats. some useful ones might include:
MSOffice (.xls, .xlxs, .doc, .docx etc), ESRI Shapefiles and File GeoDatabases (.shp), SQL dumps (.sql), Address geocoder to lat/lng ("123 fake street")
View
1 csv-server.js
@@ -1 +0,0 @@
-require('./csv').listen(80)
View
0 csv.js → csv-to-json/lib.js
File renamed without changes.
View
10 package.json → csv-to-json/package.json
@@ -1,10 +1,10 @@
{
- "name": "gut",
- "subdomain": "gutcsv",
- "start": "csv-server.js",
+ "name": "csv-to-json",
+ "subdomain": "csvtojson",
+ "start": "server.js",
"scripts": {
- "test": "node test/csv.js",
- "start": "csv-server.js"
+ "test": "node ../test/csv-to-json.js",
+ "start": "server.js"
},
"version": "0.0.1-2",
"dependencies": {
View
1 csv-to-json/server.js
@@ -0,0 +1 @@
+require('./lib').listen(80)
View
0 json-function-transform/lib.js
No changes.
View
15 json-function-transform/package.json
@@ -0,0 +1,15 @@
+{
+ "name": "json-function-transform",
+ "subdomain": "jsontransform",
+ "start": "server.js",
+ "scripts": {
+ "test": "node ../test/json-function-transform.js",
+ "start": "server.js"
+ },
+ "version": "0.0.1",
+ "dependencies": {
+ "async": "0.1.x",
+ "request": "2.1.x",
+ "underscore": "1.1.x"
+ }
+}
View
1 json-function-transform/server.js
@@ -0,0 +1 @@
+require('./lib').listen(80)
View
22 json-to-csv/lib.js
@@ -0,0 +1,22 @@
+var csv = require('csv')
+ , http = require('http')
+ , request = require('request')
+ , stream = require('stream')
+ ;
+
+module.exports = http.createServer(function (req, res) {
+ var json = ""
+ var jsonStream = new stream.Stream();
+ jsonStream.writeable = true;
+ jsonStream.readable = true;
+
+ csv()
+ .fromStream(jsonStream)
+ .toStream(res)
+
+ req.on('data', function(data) { json += data })
+ req.on('end', function() {
+ jsonStream.emit('data', new Buffer(json))
+ jsonStream.emit('end')
+ })
+})
View
16 json-to-csv/package.json
@@ -0,0 +1,16 @@
+{
+ "name": "json-to-csv",
+ "subdomain": "jsontocsv",
+ "start": "server.js",
+ "scripts": {
+ "test": "node ../test/json-to-csv.js",
+ "start": "server.js"
+ },
+ "version": "0.0.1",
+ "dependencies": {
+ "csv": "0.0.x",
+ "async": "0.1.x",
+ "request": "2.1.x",
+ "underscore": "1.1.x"
+ }
+}
View
1 json-to-csv/server.js
@@ -0,0 +1 @@
+require('./lib').listen(80)
View
0 test/csv.js → test/csv-to-json.js
File renamed without changes.

0 comments on commit 579e0fa

Please sign in to comment.