Open kjappelbaum opened 4 years ago
When we are parsing this kind of specific file I would always make the difference between the parser that tries to extract ALL the data as close as possible to the original data and then to pickup what we need to be close to our requirements. (practically 2 variables, meta and spectra).
We can export this parser that is very close to the original file as well so that it could be reused by other packages.
ok, in this approach the parsers directly tried to map to our metadata schema but moving forward the approach you mention certainly makes more sense.
Couple of tips:
import XLSX from 'xlsx';
export function getMatrixFromXLSX(blob) { const workbook = XLSX.read(blob, { type: 'array' }); return XLSX.utils.sheet_to_json(workbook.Sheets[workbook.SheetNames[0]], { header: 1, }); }
In this case the result contain something like
meta: {} // key / value with all the information in the header
variables: [] // array of object (variable)
variable will have as property: label, units, data:[]
this is an excel file
8Rubotherm gravimetric (Single gas_high pressure).xls.zip