Created
May 28, 2014 15:09
-
-
Save pewerner/9b445f697a9a683bf248 to your computer and use it in GitHub Desktop.
Parse Reader data from spectramax and rewrite it to a work list
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// JScript source code | |
open("C:\\VWorks Workspace\\Scripts\\file_operations.js") | |
//--Change this directory to be the directory that VWorks generates the output file too | |
var output_directory = "C:\\VWorks Workspace\\Scripts\\readerdata\\output\\" | |
//--Date Time Stamp Generating functions------------- | |
function make2Digits(instr) { | |
if (instr.length == 1) | |
instr = "0" + instr | |
return instr | |
} | |
function getTimeString() { | |
var ts = new Date(); | |
return ts.getFullYear() + | |
make2Digits(new String(ts.getMonth() + 1)) + | |
make2Digits(new String(ts.getDate())) + | |
make2Digits(new String(ts.getHours())) + | |
make2Digits(new String(ts.getMinutes())) + | |
make2Digits(new String(ts.getSeconds())) | |
} | |
//--End of Date Time Stamp Generating Functions | |
//--This will generate the file name of the output file. Everytime we load readerdata.js, this variable is initialized with the current data time so you only want to initialize | |
//--this once per batch. | |
var output_file = output_directory + getTimeString() + "_output.csv" | |
//-- input = path to the file generated by the reader, barcode = the plate id, head = weather or not to include the header, if this is 1 we will use the header. | |
function generateInputFile(input, barcode, head) { | |
var contents = file_read(input) | |
//--This magic grabs the stuff from the file that we want, don't ask, its magic. | |
var readerData = contents.match(/\bGroup: Unknowns 1\b[\s\S]+?(~End)/) | |
readerData = readerData[0] | |
//--Include the header if head == 1 | |
if (head == 1) { | |
rdArray = readerData.split("\n") | |
var header = rdArray[1].split("\t") | |
header.unshift("Plate ID") | |
file_write(output_file, header) | |
} | |
//--Loop Through the good stuff and add the plate id to each line, write it to a file. | |
for (var i = 2; i < 98; ++i) { | |
var line = rdArray[i].split("\t") | |
line.unshift(barcode) | |
file_write(output_file, line) | |
} | |
} | |
//--Example implementation | |
//generateInputFile("C:\\VWorks Workspace\\Scripts\\readerdata\\2014_05_20_12h48m28s.txt", "New Barcode", 1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment