45 lines
1.3 KiB
JavaScript
45 lines
1.3 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: col0,
|
|
title: col1,
|
|
elementID: col2,
|
|
elementName: col3,
|
|
scaleID: col4,
|
|
scaleName: col5,
|
|
dataValue: col6,
|
|
n: col7,
|
|
standardError: col8,
|
|
lowerCI: col9,
|
|
upperCI: col10,
|
|
recommendSuppress: col11,
|
|
notRelevant: col12,
|
|
date: col13,
|
|
domainSource: col14
|
|
};
|
|
}
|
|
|
|
export default parseLine;
|