diff --git a/README.md b/README.md index f76874a..e8924b2 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,7 @@ A text extraction node module. * ODG, OTG * PNG, JPG, GIF * DXF +* `application/csv` * `application/javascript` * All `text/*` mime-types. diff --git a/lib/extractors/text.js b/lib/extractors/text.js index 097fabb..7b5ab6f 100644 --- a/lib/extractors/text.js +++ b/lib/extractors/text.js @@ -11,6 +11,6 @@ var extractText = function( filePath, options, cb ) { }; module.exports = { - types: [/text\//, "application/javascript"], + types: [/text\//, "application/csv", "application/javascript"], extract: extractText }; \ No newline at end of file diff --git a/package.json b/package.json index 9f52120..abc4986 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "textract", "extract", "html", + "csv", "text", "pdf", "docx", diff --git a/test/extract_test.js b/test/extract_test.js index 45e7572..14d88da 100644 --- a/test/extract_test.js +++ b/test/extract_test.js @@ -2,6 +2,36 @@ var path = require('path'); describe('textract', function() { + describe('for .csv files ', function() { + + // is some oddness testing html files, not sure what the deal is + + it('from csv files', function(done) { + var docPath = path.join( __dirname, "files", "csv.csv" ); + fromFileWithPath(docPath, function( error, text ) { + expect(error).to.be.null; + expect(text).to.be.an('string'); + expect(text.length).to.eql( 18 ); + expect(text.substring(0, 80)).to.eql("Foo,Bar Foo2,Bar2 ") + done(); + }); + }); + + it('it will extract text from csv files and insert newlines in the right places', function(done) { + var docPath = path.join( __dirname, "files", "csv.csv" ); + fromFileWithPath(docPath, {preserveLineBreaks:true}, function( error, text ) { + expect(error).to.be.null; + expect(text).to.be.an('string'); + expect(text.length).to.eql( 18 ); + expect(text.substring(0, 80)).to.eql("Foo,Bar\nFoo2,Bar2\n") + done(); + }); + }); + + + + }); + describe('for .html files', function() { // is some oddness testing html files, not sure what the deal is