Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

init commit

  • Loading branch information...
commit de14a57ff1c2eaf8bc6ccde964c50e38d32a73e3 0 parents
@olalonde authored
15 .gitignore
@@ -0,0 +1,15 @@
+lib-cov
+*.seed
+*.log
+*.csv
+*.dat
+*.out
+*.pid
+*.gz
+
+pids
+logs
+results
+
+node_modules
+npm-debug.log
3  README.md
@@ -0,0 +1,3 @@
+# Reference
+
+http://nodejs.org/api/all.html#all_require_extensions
4 examples/index.js
@@ -0,0 +1,4 @@
+require('../');
+var data = require('./data.csv');
+
+console.log(data);
11 index.js
@@ -0,0 +1,11 @@
+// @see http://nodejs.org/api/all.html#all_require_extensions
+var fs = require('fs')
+ , csv2array = require('csv2array');
+
+require.extensions['.csv'] = function(module, filename) {
+ var content = fs.readFileSync(filename, 'utf8');
+ // Parse the file content and give to module.exports
+ var content = csv2array(content);
+ module.exports = content;
+};
+
23 package.json
@@ -0,0 +1,23 @@
+{
+ "name": "require-csv",
+ "version": "0.0.1",
+ "description": "require('require-csv') lets you load CSV files using require syntax. For example: var data = require('./data.csv');",
+ "main": "index.js",
+ "scripts": {
+ "test": "echo \"Error: no test specified\" && exit 1"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git@github.com:olalonde/require-csv.git"
+ },
+ "keywords": [
+ "require",
+ "csv",
+ "better-require"
+ ],
+ "author": "Olivier Lalonde <olalonde@gmail.com>",
+ "license": "BSD",
+ "dependencies": {
+ "csv2array": ""
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.