diff --git a/benchtop-fe/src/parsers/Transducer.js b/benchtop-fe/src/parsers/Transducer.js index 4ab0fa8..2e21835 100644 --- a/benchtop-fe/src/parsers/Transducer.js +++ b/benchtop-fe/src/parsers/Transducer.js @@ -15,8 +15,6 @@ export default function parseTransducer(content, accuracy){ // Split the content into sections based on the blank line const sections = content.trim().split("\n\n"); - debugger - for (const section of sections) { // Split each section into lines const lines = section.trim().split("\n"); @@ -27,15 +25,16 @@ export default function parseTransducer(content, accuracy){ // Extract the Transducer number and Transducer type const transducerLine = filteredLines.shift().trim(); - const [_, transducerName, partNumber] = transducerLine.split(null, 2); + let [transducerName, partNumber] = transducerLine.split(/\s\s+/); // Get part number and values let value = null; let unit = null; let transducerType = null; if (partNumber !== "Custom") { - value = partNumber.split(" ").pop(); - partNumber = partNumber.split(" ")[1]; + partNumber = partNumber.split(" ") + value = partNumber.pop(); + partNumber = partNumber.join(" "); const match = value.match(/([0-9]+)([A-Z]+)/i); if (match) { [, value, unit] = match; @@ -73,7 +72,7 @@ export default function parseTransducer(content, accuracy){ transducerInfo["Verify Time"] = val; } else { // Toss anything else where it belongs - const [, cleanKey] = key.split(/\W\d/); + const [cleanKey, _] = key.split(/\W\d/); if ( cleanKey in transducerInfo || key.includes(`Instrument ${transducerType}`) diff --git a/benchtop-fe/src/parsers/__tests__/parseTransducer.test.js b/benchtop-fe/src/parsers/__tests__/parseTransducer.test.js index 25820a7..39e6364 100644 --- a/benchtop-fe/src/parsers/__tests__/parseTransducer.test.js +++ b/benchtop-fe/src/parsers/__tests__/parseTransducer.test.js @@ -4,5 +4,6 @@ import parseTransducer from "../Transducer" const file = fs.readFileSync("src/parsers/__tests__/transducer_verify.txt", 'utf8') test('Check if 1 equals 1', () => { - parseTransducer(file, 0.05) + const transducer = parseTransducer(file, 0.05) + console.log(transducer) }); \ No newline at end of file