BeeHay Posted July 30, 2012 Share Posted July 30, 2012 Hello again almighty Guru! I have put our "reverse engineered" chromatograph on the back burner, and have decided that "in-the-mean-time" I'll just utilize the output file from the chromats working program... It is actually a .log file, but to get this to work, I have to convert the file to a .csv file... If I could get it to work with the .log file that would be ideal, but it's not a deal breaker and for the speed of things, a .csv will be fine... For now I have this working - private handlec = File.Open("C:\DaqFactory\Data\Chrom.csv", 1, 0, 0, 1)try V.C1Methane = File.ReadDelim(handlec,4,",",chr(10),0) File.SeekToBegin(handlec) V.C2Ethane = File.ReadDelim(handlec,7,",",chr(10),0) File.SeekToBegin(handlec) V.C3Propane = File.ReadDelim(handlec,10,",",chr(10),0) File.SeekToBegin(handlec) V.C4isobutane = File.ReadDelim(handlec,13,",",chr(10),0) File.SeekToBegin(handlec) V.C5nbutane = File.ReadDelim(handlec,16,",",chr(10),0) File.SeekToBegin(handlec) catch()endcatchFile.Close(handlec)//V.ChromTime = File.ReadDelim(handlec, 2, ",", chr(10), 0)//File.SeekToBegin(handlec)//private string chromfile//chromfile = DoubleToStr(Parse(handlec, 2, ",")//V.ChromTime = chromfile[/CODE]The last few rem'ed out lines are what I was trying out to get my "pre-formatted" time number read into the V.ChromTime variable...It looks like it only reads in the 1st digit (in this case, 7)Also, it works great to read in the 1st line of the .csv file, but alas, I need the last line read in...(Need to utilize NumRows?)Another question, if tab is my delimeter, do I just typein "Tab" like this - File.ReadDelim(handle, "Tab", chr(10), 0) ??Here are links to the .csv and .log file (can't attach them?) -http://www.auto-logg...files/chrom.csvhttp://www.auto-logg...files/chrom.logAlso attached is a .ctl file I am messing with...(my spectrum graph is just a tester )As always, ANY info is great!BeeHay Link to comment Share on other sites More sharing options...
AzeoTech Posted July 31, 2012 Share Posted July 31, 2012 Sorry, those links didn't work. Can you simply cut/paste a snippet? You can't attach them because of their extension. I believe only .ctl files and images can be attached. Also, don't forget ? strLastError inside your catch(). Link to comment Share on other sites More sharing options...
BeeHay Posted August 1, 2012 Author Share Posted August 1, 2012 Sorry for the delay, I prob tacked on 2k miles in the last 2 days running to different wellsites! Here is the snippet from the .log file - kcdc 44-8 rd2-711.CHR 7/12/2012 07:31:59 "Methane" 407.1269 "ppm" "Ethane" 57.5045 "ppm" "Propane" 64.9144 "ppm" "IsoButane" 15.7887 "ppm" "n-Butane" 58.7744 "ppm"kcdc 44-8 rd2-712.CHR 7/12/2012 07:36:29 "Methane" 404.2948 "ppm" "Ethane" 61.0093 "ppm" "Propane" 69.0660 "ppm" "IsoButane" 16.3523 "ppm" "n-Butane" 61.7767 "ppm"kcdc 44-8 rd2-713.CHR 7/12/2012 07:40:59 "Methane" 762.7927 "ppm" "Ethane" 96.0900 "ppm" "Propane" 138.9223 "ppm" "IsoButane" 11.8313 "ppm" "n-Butane" 133.5688 "ppm"kcdc 44-8 rd2-714.CHR 7/12/2012 07:45:29 "Methane" 654.2871 "ppm" "Ethane" 64.2624 "ppm" "Propane" 98.4758 "ppm" "IsoButane" 11.6475 "ppm" "n-Butane" 107.2342 "ppm"kcdc 44-8 rd2-715.CHR 7/12/2012 07:49:59 "Methane" 491.9335 "ppm" "Ethane" 54.5848 "ppm" "Propane" 52.6266 "ppm" "IsoButane" 15.1985 "ppm" "n-Butane" 49.3462 "ppm"kcdc 44-8 rd2-716.CHR 7/12/2012 07:54:29 "Methane" 422.1043 "ppm" "Ethane" 48.7556 "ppm" "Propane" 38.3322 "ppm" "IsoButane" 15.5408 "ppm" "n-Butane" 33.8624 "ppm"kcdc 44-8 rd2-717.CHR 7/12/2012 07:59:00 "Methane" 631.4674 "ppm" "Ethane" 46.1308 "ppm" "Propane" 34.7776 "ppm" "IsoButane" 17.4451 "ppm" "n-Butane" 31.9406 "ppm"kcdc 44-8 rd2-718.CHR 7/12/2012 08:03:30 "Methane" 724.5304 "ppm" "Ethane" 50.3468 "ppm" "Propane" 35.0770 "ppm" "IsoButane" 17.0169 "ppm" "n-Butane" 36.2111 "ppm"[/CODE]I do want to get the time in a variable so I can place the gas data accordingly...Also, sorry my above attached .ctl file is a "hack-job"....I was in a hurry to pull the stuff from our running .ctl file for something to post...So my goal as of now is - read in the last line (newest) data and read in the time to a variable..Thanks again! Link to comment Share on other sites More sharing options...
AzeoTech Posted August 1, 2012 Share Posted August 1, 2012 2K miles? Wow, you need DAQConnect I can't tell if this file is tab delimited or fixed width fields. Looks like maybe fixed width fields with a carriage return at the end. In that case, open the file with the text flag set true, the loop through reading a whole line at a time using file.read() until it reaches the end of the file. Then, whatever the last read was is the contents of the last line. Parsing that string is easy because its fixed field width. Just use mid() to separate out each field. Converting the date/time stamp is also simple, just use the strToTime() function (section 4.12.11). Link to comment Share on other sites More sharing options...
BeeHay Posted August 2, 2012 Author Share Posted August 2, 2012 Thanks for the pointers...Not sure how to advance line by line to the end of the document... Can I throw in a File.SeekToEnd() somehow in there??? Still kinda having a tough time, and I think I am cheating doing it this way - private handlec = File.Open(chromfile, 1, 0, 0, 1)try private string f = File.Read(handlec) V.C1Methane = Mid(f, 51, 10) catch() ?strLastErrorendcatch[/CODE]I am getting a value, but again, it is the 1st line, and I'm sure there is another way of reading in the "fields"...I'll keep toying with it 'till I get somewhere..About DAQConnect -Can I control my .ctl file through DAQConnect??I'm not expecting to be able to make script changes, but can I click certian buttons to get to different pages or set variables?Thanks again! Link to comment Share on other sites More sharing options...
AzeoTech Posted August 7, 2012 Share Posted August 7, 2012 You simply do file.read() until it returns a blank line or throws an error (I can't remember which occurs when you get to the end of file). Then just use the last non-empty reading. You can't use seekToEnd because your line lengths are variable, though actually, maybe they aren't, since they appear fixed width. You might be able to seekToEnd() then go back a certain # of characters then read. As for DAQConnect, yes, you can have DAQConnect send commands to DAQFactory. What you do with those commands is up to you. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.