43 lines
1.5 KiB
JavaScript
43 lines
1.5 KiB
JavaScript
// parseLine.js
|
|
function parseLine(line) {
|
|
// Split on tabs
|
|
const cols = line.split(/\t/).map((c) => c.trim());
|
|
|
|
// We expect 15 columns, but we won't skip lines if some are missing or extra.
|
|
// We'll fill them with "" if not present, to preserve all data
|
|
const col0 = cols[0] || ""; // O*NET-SOC Code
|
|
const col1 = cols[1] || ""; // Title
|
|
const col2 = cols[2] || ""; // Element ID
|
|
const col3 = cols[3] || ""; // Element Name
|
|
const col4 = cols[4] || ""; // Scale ID
|
|
const col5 = cols[5] || ""; // Scale Name
|
|
const col6 = cols[6] || ""; // Data Value
|
|
const col7 = cols[7] || ""; // N
|
|
const col8 = cols[8] || ""; // Standard Error
|
|
const col9 = cols[9] || ""; // Lower CI Bound
|
|
const col10 = cols[10] || ""; // Upper CI Bound
|
|
const col11 = cols[11] || ""; // Recommend Suppress
|
|
const col12 = cols[12] || ""; // Not Relevant
|
|
const col13 = cols[13] || ""; // Date
|
|
const col14 = cols[14] || ""; // Domain Source
|
|
|
|
// Return an object with keys matching your definitions
|
|
return {
|
|
onetSocCode: cols[0], // e.g. "11-1011.00"
|
|
elementID: cols[1], // e.g. "2.C.1.a"
|
|
elementName: cols[2], // e.g. "Administration and Management"
|
|
scaleID: cols[3], // e.g. "IM" or "LV"
|
|
dataValue: cols[4], // e.g. "4.78"
|
|
n: cols[5], // e.g. "28"
|
|
standardError: cols[6], // e.g. "0.1102"
|
|
lowerCI: cols[7],
|
|
upperCI: cols[8],
|
|
recommendSuppress: cols[9],
|
|
notRelevant: cols[10],
|
|
date: cols[11],
|
|
domainSource: cols[12]
|
|
};
|
|
}
|
|
|
|
export default parseLine;
|