https://github.com/abhinaba-ghosh/any-text
Get text content from any file
https://github.com/abhinaba-ghosh/any-text
file-reader reader text text-extraction text-extractor
Last synced: 11 months ago
JSON representation
Get text content from any file
- Host: GitHub
- URL: https://github.com/abhinaba-ghosh/any-text
- Owner: abhinaba-ghosh
- License: mit
- Created: 2020-07-08T13:38:26.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2024-08-17T18:14:18.000Z (almost 2 years ago)
- Last Synced: 2024-10-30T04:49:32.751Z (over 1 year ago)
- Topics: file-reader, reader, text, text-extraction, text-extractor
- Language: JavaScript
- Homepage:
- Size: 226 KB
- Stars: 61
- Watchers: 2
- Forks: 11
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Any-Text
Extract text content from a file.
### Supported File Extensions
- DOC
- DOCX
- DOT
- PDF
- CSV
- TXT
- XLS
- XLSX
- JSON
### How to use
- Install the library as a dependency (/dev-dependency)
```ssh
npm i -D any-text
```
- Make use of the `getText` method to read the text content
```js
var reader = require('any-text');
reader
.getText(`path-to-file`)
.then(function (data) {
console.log(data); // handle success
})
.catch(function (error) {
console.log(error); // handle error
});
```
- You can also use the `async/await` notation
```js
var reader = require('any-text');
const text = await reader.getText(`path-to-file`);
console.log(text);
```
### Sample Test
```js
var reader = require('any-text');
const chai = require('chai');
const expect = chai.expect;
describe('file reader checks', () => {
it('check docx file content', async () => {
expect(await reader.getText(`${process.cwd()}/test/files/dummy.docx`)).to.contains(
'Lorem ipsum'
);
});
});
```
### Tell me your issues
you can raise any issue [here](https://github.com/abhinaba-ghosh/any-text/issues)
### Contribution
Any pull request is welcome.
If it works for you , give a [Star](https://github.com/abhinaba-ghosh/any-text)! :star:
_- Copyright © 2020- [Abhinaba Ghosh](https://www.linkedin.com/in/abhinaba-ghosh-9a2ab8a0/)_