0.0.6 • Published 6 years ago

@botflx/data-converter v0.0.6

Weekly downloads
-
License
MIT
Repository
-
Last release
6 years ago

Map

Maps are declared is a JSON file like below.

{
  "map": {
    "documentRoot": "Root",
    "collectionRoot": "Element",
    "fields": [
      {
        "name": "Year",
        "columns": ["year"],
        "type": "string"
      }, {
        "name": "FullName",
        "columns": ["first_name", "last_name"],
        "type": "string",
        "concatenation": " "
      }, {
        "name": "FirstName",
        "columns": ["names"],
        "type": "string",
        "afterFilters": [
          {
            "name": "getWord",
            "args": { "word": 0 }
          }
        ]
      }
    ]
  }
}
NameDescriptionType
documentRootDefines the name of the root element, usefull when using XML.string
collectionRootDefines the name of the collection.string
documentAttributesDefines attributes for the root element usefull for XML-based format.Object
documentDeclarationDefines declaration for the document.Object
fieldsDescribes the fields needed in the result filearray

Fields

NameDescriptionType
nameDefines the fields namestring
columnsDefines columns used for constructing the fieldarray
typeDefines the type of this field. The type will be used for validating the data.string
concatenationDefines how columns need to be mergestring
afterFiltersDefines which filter need to be applied on the resulting dataarray

How does it works ?

  1. Takes the file and read each row
  2. For each row it itirate though all map fields
  3. For each map field it process specified columns
    1. Firstly it merge columns of there is multiple
    2. Secondly it apply filters defined in after filter
    3. It checks the type
  4. When all rows are process it converts the content into XML.

How to run ?

Install dependecies

npm i

Start the project

node app.js inputPath=/path/to/input.csv mapPath=/path/to/map.json outputPath=/path/to/output.xml

TODO

  • Test for files util
  • Message bag
  • Refactor message-bag so it can be fonctionnal
0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago

0.0.0

6 years ago