Fixy is an npm module for parsing fixed formatted strings/files.
npm install fixy --save
var fixy = fixy.parse({
map: [{
name: "Age",
width: 2,
start: 1,
type: "int"
}],
options: {
fullwidth: 2,
skiplines: null,
format: "json" //default
}
},"30ABC20151201Y950");
A map [array of objects] of the column names, width, starting point, type of value, extra type settings.
- Integer
- type : "int"
- name (Required) | Name of the Column
- width (Required) | Length of Column
- start (Required) | Start of Column in Row
- Float
- type : "float"
- name (Required) | Name of the Column
- width (Required) | Length of Column
- start (Required) | Start of Column in Row
- percision (Required) | Float Percision Value (Ex: 9.20 is 2)
- Date
- type : "date"
- name (Required) | Name of the Column
- width (Required) | Length of Column
- start (Required) | Start of Column in Row
- inputformat (Required) | Format Date Date is Currently In
- outputformat (Required) | Format Date Date is Returned As
- String
- type : "string"
- name (Required) | Name of the Column
- width (Required) | Length of Column
- start (Required) | Start of Column in Row
- Boolean
- type : "bool"
- name (Required) | Name of the Column
- width (Required) | Length of Column
- start (Required) | Start of Column in Row
- tVal (Required) | String Value of True
- fVal (Required) | String Value of False
- fullwidth = full length / width of row from start to end
- skiplines = optional array of rows to be skipped. May be left null
- format = defaults "json". Valid selections are: json, csv