Logging Data From A Text File


Recommended Posts

Hi,

I would like to read data into Daqfactory from a file created by a Campbell Scientific datalogger. An example of the file is attached. The file is appended to every minute and I would like to read the most recent (bottom) line and parse the comma delimited data into different channels. So firstly is this possible and any help to do it would be much appreciated.

Thanks

current.txt

Link to comment
Share on other sites

It is possible and is not hard to do except for trying to figure out what the last line is. Since its a delimited file and not fixed field length, you can't simply calculate where the last line is. There are a couple ways you can do it. You can either use file.readDelim(), along with File.open() and File.Close() to read the entire file and then look at the last line of the array and compare the time stamp with the last read value. Or you can get the length of the file, then subtract some amount that is bigger than any one line would be, maybe 200? and skip to that part of the file. Then do file.readDelim() and only look at the last line. This is probably the better method because the first method will get slower as the file gets bigger.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.