Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ngudbhav/excel-to-mongodb
This module converts your correctly formatted Excel spreadsheet to a collection in the specified database in MongoDB.
https://github.com/ngudbhav/excel-to-mongodb
excel excel-to-mongo mongo mongodb mongoose npm npm-install npm-module npm-package
Last synced: 2 months ago
JSON representation
This module converts your correctly formatted Excel spreadsheet to a collection in the specified database in MongoDB.
- Host: GitHub
- URL: https://github.com/ngudbhav/excel-to-mongodb
- Owner: ngudbhav
- License: mit
- Created: 2018-10-13T16:53:43.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2022-10-15T17:05:18.000Z (about 2 years ago)
- Last Synced: 2024-10-06T20:34:14.515Z (3 months ago)
- Topics: excel, excel-to-mongo, mongo, mongodb, mongoose, npm, npm-install, npm-module, npm-package
- Language: JavaScript
- Homepage: https://npm.im/excel-to-mongodb
- Size: 89.8 KB
- Stars: 9
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# excel-to-mongoDB
[![Build Status](https://travis-ci.com/ngudbhav/excel-to-mongoDB.svg?branch=master)](https://travis-ci.com/ngudbhav/excel-to-mongoDB)
[![CircleCI](https://circleci.com/gh/ngudbhav/excel-to-mongoDB.svg?style=svg)](https://circleci.com/gh/ngudbhav/excel-to-mongoDB)This module converts your correctly formatted Excel spreadsheet to a collection in specified database in MongoDB.
## Excel Formats Supported
Supported Excel formats are XLS/XLSX/CSV
## Spreadsheet Format
Please have a look at the sample Excel sheets provided to have a clear view of the File. Microsoft Sample Sheet
## Installation
```sh
npm install excel-to-mongoDB --save
```## Testing
```sh
git clone https://github.com/ngudbhav/excel-to-mongoDB.git
cd excel-to-mongoDB/
```Navigate to the folder.
```sh
cd test/
nano test.js
```Now this file needs the MongoDB credentials. Provide those credentials in String format and save by pressing the following keys.
```sh
'CTRL+X'
'Y'
'Return'
```Get back and test the module.
```sh
cd ..
npm test
```## Using
Note: Please correctly format the Excel sheet else this won't work.
```sh
var excelMongo = require('excel-to-mongoDB');
```This module needs 3 arguments.
The first one is the object with your credentials.```sh
var credentials = {
host: host,
path: path for the excel file,
collection: Collection name for creation,
db: Your Database name,
user: username for authentication. Leave blank if no authentication required,
pass: password for authentication.
connection: Connection Object from mongodb client. Leave blank to create a connection,
endConnection*:
};
```* Please note that endConnection false may not terminate the process.
The second one is an optional argument of options with default values as follows.
```sh
var options = {
safeMode: false //Backup the db to the current working directory in dump/ folder.
verbose: false //Console.log the current step processing.
customStartEnd: false //Custom insert the row and columns rather than full excel-file. Do take care! Specifying endRow or endCol may result in insertion of redundant data.
startRow: //Valid only if customStartEnd is true. Defines the start Row of the data.
endRow: //Valid only if customStartEnd is true. Defines the end Row of the data.
startCol: //Valid only if customStartEnd is true. Defines the start Column of the data.
endCol: //Valid only if customStartEnd is true. Defines the end Column of the data.
destination: '' // Valid only if safeMoode is true. Defines the destination of the dump file of db
}
```The third argument is the callback function which should be executed.
```sh
try {
excelMongo.covertToMongo(credentials, options, callback); //returns documents inserted in the database.
} catch(error) {
throw error;
}
````try/catch` is always recommended because of the type of errors that can occur.
## Error in safeMode option
```sh
Windows users need to add the following path to the environment path variable.
C:\Program Files\MongoDB\Server\\binRight click 'This PC', head to 'properties' and 'Advanced System Settings'. From there, Click on 'Environment Variables'. Under System Variables, Search for 'PATH'. Double click the entry, click on new and add the above path.
Restart your console and you should be good to go.Linux/Unix Users please check your installation or .bashrc.
```## Want to covert to MYSQL instead?
We have got you covered! GitHub Link.
## Want to use the GUI instead?
We have got you covered! GitHub Link.