hesham.m.mahrous Posted February 8, 2012 Share Posted February 8, 2012 I developed a ctl that runs on a tablet PC that is connected to a printer. The client wants to be able to print his logged data from the CSV file by selecting his data range and click on a button using daq factory since using a mouse is a limited option and doing it without using a mouse is not as convenient. What I am looking at is to search the date and time on a CSV file that is logged by the DAQ logger then access the corresponding rows and print it in the same order it is displayed in the CSV file. Can I do that ? Link to comment Share on other sites More sharing options...
AzeoTech Posted February 9, 2012 Share Posted February 9, 2012 You can, but if the data is stored across multiple files, then you are going to have to write a fancy algorithm for cycling through the files. If the data is in one file, then its pretty easy. Truthfully, the best thing would be to log the data to a MySQL database, then you can query for exactly what you need through SQL. But, if you are using a single file, you'll want to use the File.Open(), File.ReadDelim() and File.Close() functions to retrieve all the data. Provided you pass -1 for the column for ReadDelim(), you'll end up with an 2 dimensional array. Time is the first column which you can filter on. So if the result of readDelim() was put in a variable called "datain", you would do: datain = filter(datain, datain[][0] >= starttime && datain[][0] <= endtime) This reduces the data set down to the desired time range. Then you can use File.Open(), WriteDelim() and Close() to write the result to a temporary file. Then to print, simply use system.shellExecute() to run Notepad.exe with the "print" option and the temporary file: system.shellExecute("notepad.exe", "print", "myTempFile.csv","","hide") Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.