UNPKG

plate-data-transfer

Version:

Rearranging plate-layouts according to liquid handling steps

41 lines (38 loc) 1.12 kB
import { // PlateSizeType, // PlateWellsType, // PlatesObjectType, TransferInstructionsRowType, TransferInstructionsType, // PlateMapRowType, // PlateMapType, // PlateRelationshipType, // ClashStrategyType, } from "../../PlateTypes"; function parseInstructionsCSV(csvString: string): TransferInstructionsType { const transferInstructions: TransferInstructionsType = []; // console.log(csvString); const csvLines: string[] = csvString.split(/\r?\n|\r/); console.dir(csvLines); csvLines.shift(); let vals: string[]; let row: TransferInstructionsRowType = { "Source Plate": "", "Source Well": "", Volume: 1, "Destination Plate": "", "Destination Well": "", }; csvLines.forEach((line) => { row = { ...row }; vals = line.split(",").map((d) => d.trim()); row["Source Plate"] = vals[0]; row["Source Well"] = vals[1]; row["Volume"] = +vals[2] ? +vals[2] : 1; row["Destination Plate"] = vals[3]; row["Destination Well"] = vals[4]; transferInstructions.push(row); }); return transferInstructions; } export default parseInstructionsCSV;