Create Comma-Separated-Values based on metadata
js
const convertToCSV = require("@a.bayat/csv_creator");
convertToCSV(
metadataPath,
readFrom,
writeTo,
(encoding = "utf-8"),
option({
progress: true,
error: false
})
);
`
Example of metadata file (metadata.txt)
`txt
Production Date,10,date
Item Description,30,string
Inventory,6,numeric
`
Metadata Structure
| Fields | Lengths | Types |
| :----------- | :-----------: | :---------- |
| | | |
| | | |
| | | |
$3
- date
- string
- numeric
Example of fixed formated file (fff.txt)
`txt
2019-10-30 Milk 22000
2019-09-15 Multi-grain Bread !? ^^@ 320
2019-08-01 Rice 480.9
`
Example of fixed formated file converted to CSV
`txt
Production Date,Item Description,Inventory
30/10/2019,milk,22000
15/09/2019,multi-grain bread,320
01/08/2019,rice,480.9
``