1.0.0 • Published 5 years ago

xlsx-to-directories v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
5 years ago

Xlsx to Direcotries Core

xlsx-to-directories module expose one functionality that take a file with .xlsx extension and create a new directory for each row in the specified ouput directory.

Structure of the .xlsx file

A1B1
1Azienda1
2Azienda2
...Azienda...

There must be two columns. Except for the first row that is intended as labels, the follwings rows must be of type number for the first column and type string for the second column.

How it works

Start parsing the file one row at a time. If it is the fist row (the row with the labels), do nothing. If the two columns of the row contains correct values, combine them into one single string. Otherwise do nothing for incorrect values. Create a new directory in the path specified in input using the new created srting as the directory name name. When there is no more rows left terminate the script.

How to use it

Install the module

npm i --save xlsx-to-directories

Import and usage

const xlsxToDir = require('xlsx-to-directories')

xlsxToDir('path_to_file', 'path_to_dir')
  .then(count => {
    console.log(`${count} new folder${count > 1 ? 's' : ''}`)
  })
  .catch(error => {
    console.error(error)
  })