Dont have a clue which program to use to process flying bat data


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Dont have a clue which program to use to process flying bat data
# 1  
Old 02-23-2011
Dont have a clue which program to use to process flying bat data

Hi, Im not a unix person but need to analyse some data.
This is bat data (animals) from large roosts using data loggers.
I think AWK is probably the best thing to use but dont really know so any help appreciated.
(python, grep) whichever it is, I'll have to learn it!

here is an example of the data downloaded from the logger. I need to make sense of it.
There are two infrared beams in sequence a few cm apart this way we can tell if it flies "in" or "out" of the roost. There is date/time attached to each record.

so the sequence as follows shows beam 1 giving a high signal (1) followed by beam 0 giving a high signal (1) then beam 1 goes low (0) then beam zero goes low (0)
Code:
(date,time,beam,signal)
20/01/2011,10:10,1,1
20/01/2011,10:10,0,1
20/01/2011,10:10,1,0
20/01/2011,10:10,0,0

the above is a single transit in directiion "A" the opposite would be a transit in direction "B" as follows:
Code:
20/01/2011,10:15,0,1
20/01/2011,10:15,1,1
20/01/2011,10:15,0,0
20/01/2011,10:15,1,0

the abvoe two examples are they only valid transits. other patterns are insects since only one beam at a time is broken e.g.
Code:
20/01/2011,10:10,1,1
20/01/2011,10:10,1,0
20/01/2011,10:10,0,1
20/01/2011,10:10,0,0

presuably I need to use arrays?
Ideally what I would like as an output is for each valid transit
date,time,1 for direction "A"
and
date,time,-1 for direction "B" this way I can use plus and minus one to stack the ins (A) and outs(B) to get cumulative maximum bats out for each day.

many thanks in advance, hoping someone can advise.Smilie

Last edited by Franklin52; 02-24-2011 at 03:24 AM.. Reason: Please use code tags, thank you
# 2  
Old 02-23-2011
Interesting. We usually don't get asked about bats around here! Smilie It would really, really help to know what system you're on. I'm writing code for junky old shells that'll take 30 lines to do what a newer one could do in 5 until you tell me you have anything better.

---------- Post updated at 01:16 PM ---------- Previous update was at 01:09 PM ----------

Code that should work in even junky old shells:
Code:
#!/bin/sh

PDATE=""
M3="" ; M2="" ; M1="" ; M0=""

while IFS="," read DAY TIME BELFRY
do
        if [ "$PDATE" != "${DAY},${TIME}" ]
        then
                PDATE="${DAY},${TIME}"
                M0="${BELFRY}"
                M1=""
                M2=""
                M3=""
                continue
        fi

        M3="${M2}" ; M2="${M1}" ; M1="${M0}"
        M0="${BELFRY}"

        if [ "${M3},${M2},${M1},${M0}" = "0,1,1,1,0,0,1,0" ]
        then
                echo "${DAY},${TIME} Transit B"
        elif [ "${M3},${M2},${M1},${M0}" = "1,1,0,1,1,0,0,0" ]
        then
                echo "${DAY},${TIME} Transit A"
        fi
done

Code:
$ cat batmon.dat
20/01/2011,10:10,1,1
20/01/2011,10:10,0,1
20/01/2011,10:10,1,0
20/01/2011,10:10,0,0
21/01/2011,10:15,0,1
21/01/2011,10:15,1,1
21/01/2011,10:15,0,0
21/01/2011,10:15,1,0
$ ./batmon.sh < batmon.dat
20/01/2011,10:10 Transit A
21/01/2011,10:15 Transit B
$

It assumes that a bat takes less than a minute to fly through the two infrared beams Smilie Usually a good assumption but there's the odd chance that a bat might hit the beam at 11:59:59.99999, and hit the second at 12:00:00.000000....
# 3  
Old 02-23-2011
shell

actullly was planning on using gawk on xP -eek! sorry. if AWK is most apprpriate (is it?)
willing to use whatever you suggest is best thouhg, ive got a fedora 14 box which I havent checked but will either beGNU bash or Bourne Again SHell.
Preumably BASH is your preference?

Last edited by cmp260; 02-23-2011 at 03:54 PM..
# 4  
Old 02-23-2011
You did say anything -- and you did say UNIX! :P

BASH == Bourne Again Shell so it's bash both ways.

The script above should run in any Bourne shell, BASH included. I've tested it with all the best and worst shells I had.

I don't think it'd be too much simpler in AWK. I'll try and figure something out.

---------- Post updated at 02:50 PM ---------- Previous update was at 02:25 PM ----------

Code:
$ cat batman.awk
BEGIN   {       FS=","; ca=0;   cb=0;   d="";   t="";   }
        {
                if(($1 != d) || ($2 != t))
                        for(n=0; n<4-1; n++)    a[n]="";
                else    for(n=0; n<4-1; n++)    a[n]=a[n+1];

                a[3]=sprintf("%s,%s",$3,$4);

                if(     (a[0] == "1,1")&&(a[1]=="0,1")  &&
                        (a[2]=="1,0")&&(a[3]=="0,0")            )
                {
                        printf("Event A\n");
                        ca++;
                }
                if(     (a[0]=="0,1")&&(a[1]=="1,1")    &&
                        (a[2]=="0,0")&&(a[3]=="1,0")            )
                {
                        printf("Event B\n");
                        cb++;
                }

                d=$1;   t=$2;
        }

END     {
                printf("A\t%d\n", ca);
                printf("B\t%d\n", cb);
        }
$ cat batmon.dat
20/01/2011,10:10,1,1
20/01/2011,10:10,0,1
20/01/2011,10:10,1,0
20/01/2011,10:10,0,0
21/01/2011,10:15,0,1
21/01/2011,10:15,1,1
21/01/2011,10:15,0,0
21/01/2011,10:15,1,0
$ awk -f batman.awk < batmon.dat
Event A
Event B
A       1
B       1
$


Last edited by Corona688; 02-23-2011 at 04:32 PM..
# 5  
Old 02-24-2011
which is better in your opinion? -p.s. data was wrong

I'm curious now, what shell would allow this to be achieved in 5 or 6 lines of code?

Further to the solutions, I got something wrong see below,Smilie (I didn't have the data to hand when I wrothe the question) and there are actually some complicating factors: the logger automatically stores the data in new directories each day, the dir name is the date (in the format 2011-01-31) but it is not stored in the line of text as I thought originally -sorry about that. Data is held in identical logfile.txt in each of the date directories but there is other data in the file that can be ignored.
If is is still even possible for the script to work properly, is there any way to run the script automatically on each of the directories in turn and append the date to the time of each transit? And even output a single file concatenating all the processed data?

below is an actual example of a logfile.txt (real bat transits) and Ive attached a series of actual files and directories as zip
Code:
Tx->06:32:34,ev,1
Rx<-06:32:35,ev,1
Tx->06:53:46,ev,1
Rx<-06:53:46,ev,1
Tx->06:54:18,ev,1
Rx<-06:54:18,ev,1
Rx<-07:01:36,pv,1,1
Rx<-07:01:36,pv,0,1
Rx<-07:01:36,pv,0,0
Rx<-07:01:36,pv,0,1
Rx<-07:01:37,pv,0,0
Rx<-07:01:37,pv,1,0
Rx<-07:01:37,pv,1,1
Rx<-07:01:38,pv,0,1
Rx<-07:01:38,pv,0,0
Rx<-07:01:38,pv,1,0
Rx<-07:02:52,pv,1,1
Rx<-07:02:53,pv,1,0
Rx<-07:04:55,pv,1,1
Rx<-07:04:55,pv,0,1
Rx<-07:04:56,pv,0,0
Rx<-07:04:56,pv,1,0
Rx<-07:05:03,pv,1,1
Rx<-07:05:04,pv,1,0
Tx->07:14:12,ev,1
Rx<-07:14:12,ev,1
Rx<-07:14:53,pv,1,1
Rx<-07:14:53,pv,0,1
Rx<-07:14:54,pv,0,0
Rx<-07:14:54,pv,1,0
Rx<-07:14:58,pv,1,1
Rx<-07:14:58,pv,0,1
Rx<-07:14:59,pv,0,0
Rx<-07:14:59,pv,1,0
Rx<-08:06:41,tv,21.5;;;;;
Rx<-08:59:20,pv,0,1
Rx<-08:59:20,pv,0,0
Rx<-08:59:20,pv,0,1
Rx<-08:59:20,pv,0,0
Rx<-08:59:20,pv,0,1
Rx<-08:59:20,pv,1,1
Rx<-08:59:20,pv,1,0
Rx<-08:59:20,pv,1,1
Rx<-08:59:20,pv,0,0
Rx<-08:59:20,pv,1,0
Rx<-09:00:26,tv,22.0;;;;;
Rx<-09:17:52,pv,0,1
Rx<-09:17:52,pv,1,1
Rx<-09:17:52,pv,0,0
Rx<-09:17:52,pv,1,0
Rx<-09:27:36,pv,0,1
Rx<-09:27:36,pv,0,0
Rx<-09:27:36,pv,1,1
Rx<-09:27:36,pv,0,1
Rx<-09:27:36,pv,1,0
Rx<-09:27:36,pv,1,1
Rx<-09:27:36,pv,1,0
Rx<-09:27:36,pv,0,0
Rx<-09:35:15,pv,0,1
Rx<-09:35:15,pv,0,0
Rx<-09:35:15,pv,0,1
Rx<-09:35:15,pv,1,1
Rx<-09:35:15,pv,0,0
Rx<-09:35:15,pv,1,0
Rx<-09:35:33,pv,1,1
Rx<-09:35:33,pv,0,1
Rx<-09:35:33,pv,1,0
Rx<-09:35:33,pv,0,0
Rx<-09:49:50,pv,1,1
Rx<-09:49:50,pv,0,1
Rx<-09:49:50,pv,1,0
Rx<-09:49:50,pv,0,0
Rx<-09:54:12,tv,22.5;;;;;
Rx<-09:58:20,pv,0,1
Rx<-09:58:20,pv,0,0
Rx<-09:58:20,pv,0,1
Rx<-09:58:20,pv,1,1
Rx<-09:58:20,pv,0,0
Rx<-09:58:20,pv,1,0
Rx<-10:06:32,pv,1,1
Rx<-10:06:32,pv,0,1
Rx<-10:06:32,pv,0,0
Rx<-10:06:32,pv,0,1
Rx<-10:06:32,pv,0,0
Rx<-10:06:32,pv,0,1
Rx<-10:06:32,pv,1,0
Rx<-10:06:32,pv,0,0
Rx<-10:19:07,pv,0,1
Rx<-10:19:07,pv,1,1
Rx<-10:19:07,pv,0,0
Rx<-10:19:07,pv,1,0
Rx<-10:33:13,pv,1,1
Rx<-10:33:13,pv,1,0
Rx<-10:33:13,pv,1,1
Rx<-10:33:13,pv,0,1
Rx<-10:33:13,pv,1,0
Rx<-10:33:13,pv,0,0
Rx<-10:47:57,tv,22.5;;;;;
Rx<-11:41:43,tv,22.5;;;;;
Rx<-11:45:56,pv,0,1
Rx<-11:45:56,pv,1,1
Rx<-11:45:56,pv,0,0
Rx<-11:45:56,pv,1,0
Rx<-11:50:00,pv,1,1
Rx<-11:50:00,pv,0,1
Rx<-11:50:00,pv,0,0
Rx<-11:50:00,pv,0,1
Rx<-11:50:00,pv,1,0
Rx<-11:50:00,pv,0,0
Rx<-11:59:41,pv,0,1
Rx<-11:59:41,pv,1,1
Rx<-11:59:41,pv,0,0
Rx<-11:59:41,pv,1,0
Rx<-11:59:49,pv,1,1
Rx<-11:59:49,pv,1,0
Rx<-11:59:49,pv,0,1
Rx<-11:59:49,pv,0,0
Rx<-11:59:49,pv,1,1
Rx<-11:59:49,pv,0,1
Rx<-11:59:49,pv,0,0
Rx<-11:59:49,pv,0,1
Rx<-11:59:49,pv,0,0
Rx<-11:59:49,pv,0,1
Rx<-11:59:49,pv,1,0
Rx<-11:59:49,pv,0,0
Rx<-11:59:49,pv,0,1
Rx<-11:59:49,pv,0,0
Rx<-12:00:16,pv,0,1
Rx<-12:00:16,pv,1,1
Rx<-12:00:16,pv,0,0
Rx<-12:00:16,pv,1,0
Rx<-12:16:07,pv,1,1
Rx<-12:16:07,pv,0,1
Rx<-12:16:07,pv,1,0
Rx<-12:16:07,pv,1,1
Rx<-12:16:07,pv,1,0
Rx<-12:16:07,pv,0,0
Rx<-12:16:07,pv,1,1
Rx<-12:16:07,pv,0,1
Rx<-12:16:07,pv,1,0
Rx<-12:16:07,pv,0,0
Rx<-12:35:28,tv,22.5;;;;;
Rx<-13:29:13,tv,22.5;;;;;
Rx<-14:22:54,tv,21.5;;;;;
Rx<-15:16:40,tv,22.5;;;;;
Rx<-15:17:29,pv,1,1
Rx<-15:17:29,pv,0,1
Rx<-15:17:29,pv,1,0
Rx<-15:17:29,pv,0,0
Rx<-15:17:29,pv,0,1
Rx<-15:17:29,pv,0,0
Rx<-15:33:30,pv,1,1
Rx<-15:33:30,pv,1,0
Rx<-15:33:30,pv,1,1
Rx<-15:33:30,pv,1,0
Rx<-15:33:30,pv,1,1
Rx<-15:33:30,pv,0,1
Rx<-15:33:31,pv,1,0
Rx<-15:33:31,pv,1,1
Rx<-15:33:31,pv,0,0
Rx<-15:33:31,pv,1,0
Rx<-15:33:31,pv,0,1
Rx<-15:33:31,pv,0,0
Rx<-15:33:31,pv,0,1
Rx<-15:33:31,pv,0,0
Rx<-15:33:31,pv,0,1
Rx<-15:33:31,pv,0,0
Rx<-15:35:23,pv,1,1
Rx<-15:35:23,pv,0,1
Rx<-15:35:23,pv,1,0
Rx<-15:35:23,pv,0,0
Rx<-15:35:24,pv,1,1
Rx<-15:35:24,pv,1,0
Rx<-15:35:24,pv,1,1
Rx<-15:35:24,pv,1,0
Rx<-15:35:24,pv,1,1
Rx<-15:35:24,pv,0,1
Rx<-15:35:24,pv,1,0
Rx<-15:35:24,pv,0,0
Rx<-16:10:25,tv,22.5;;;;;
Rx<-16:26:09,pv,1,1
Rx<-16:26:09,pv,1,0
Rx<-16:26:09,pv,1,1
Rx<-16:26:09,pv,1,0
Rx<-16:26:09,pv,1,1
Rx<-16:26:09,pv,1,0
Rx<-16:26:09,pv,1,1
Rx<-16:26:09,pv,1,0
Rx<-16:26:09,pv,1,1
Rx<-16:26:09,pv,0,1
Rx<-16:26:09,pv,0,0
Rx<-16:26:09,pv,0,1
Rx<-16:26:09,pv,0,0
Rx<-16:26:09,pv,0,1
Rx<-16:26:09,pv,1,0
Rx<-16:26:09,pv,0,0
Rx<-16:26:10,pv,0,1
Rx<-16:26:10,pv,0,0
Rx<-16:26:10,pv,0,1
Rx<-16:26:10,pv,0,0
Rx<-16:26:10,pv,0,1
Rx<-16:26:10,pv,0,0
Rx<-17:00:51,pv,1,1
Rx<-17:00:51,pv,1,0
Rx<-17:00:51,pv,1,1
Rx<-17:00:51,pv,0,1
Rx<-17:00:51,pv,0,0
Rx<-17:00:51,pv,0,1
Rx<-17:00:51,pv,1,0
Rx<-17:00:51,pv,0,0
Rx<-17:04:10,tv,22.5;;;;;
Rx<-17:22:08,pv,0,1
Rx<-17:22:08,pv,0,0
Rx<-17:22:08,pv,0,1
Rx<-17:22:08,pv,1,1
Rx<-17:22:08,pv,0,0
Rx<-17:22:08,pv,1,0
Rx<-17:27:04,pv,0,1
Rx<-17:27:04,pv,0,0
Rx<-17:27:04,pv,0,1
Rx<-17:27:04,pv,1,1
Rx<-17:27:04,pv,0,0
Rx<-17:27:04,pv,0,1
Rx<-17:27:04,pv,0,0
Rx<-17:27:04,pv,1,0
Rx<-17:27:04,pv,1,1
Rx<-17:27:04,pv,1,0
Rx<-17:27:04,pv,1,1
Rx<-17:27:04,pv,1,0
Rx<-17:32:54,pv,0,1
Rx<-17:32:54,pv,1,1
Rx<-17:32:54,pv,1,0
Rx<-17:32:54,pv,1,1
Rx<-17:32:54,pv,0,0
Rx<-17:32:54,pv,1,0
Rx<-17:32:54,pv,1,1
Rx<-17:32:54,pv,1,0
Rx<-17:33:19,pv,1,1
Rx<-17:33:19,pv,1,0
Rx<-17:33:19,pv,1,1
Rx<-17:33:19,pv,1,0
Rx<-17:33:19,pv,1,1
Rx<-17:33:19,pv,1,0
Rx<-17:33:19,pv,1,1
Rx<-17:33:19,pv,1,0
Rx<-17:34:17,pv,0,1
Rx<-17:34:17,pv,1,1
Rx<-17:34:17,pv,0,0
Rx<-17:34:17,pv,1,0
Rx<-17:35:52,pv,0,1
Rx<-17:35:52,pv,0,0
Rx<-17:35:52,pv,0,1
Rx<-17:35:52,pv,0,0
Rx<-17:35:52,pv,0,1
Rx<-17:35:52,pv,0,0
Rx<-17:35:52,pv,0,1
Rx<-17:35:52,pv,1,1
Rx<-17:35:52,pv,0,0
Rx<-17:35:52,pv,0,1
Rx<-17:35:52,pv,0,0
Rx<-17:35:52,pv,0,1
Rx<-17:35:52,pv,0,0
Rx<-17:35:52,pv,1,0
Rx<-17:40:58,pv,0,1
Rx<-17:40:58,pv,1,1
Rx<-17:40:58,pv,1,0
Rx<-17:40:58,pv,1,1
Rx<-17:40:58,pv,0,0
Rx<-17:40:58,pv,1,0
Rx<-17:57:56,tv,22.0;;;;;
Rx<-18:36:44,pv,1,1
Rx<-18:36:44,pv,1,0
Rx<-18:36:44,pv,1,1
Rx<-18:36:44,pv,1,0
Rx<-18:36:44,pv,1,1
Rx<-18:36:44,pv,1,0
Rx<-18:36:44,pv,1,1
Rx<-18:36:44,pv,0,1
Rx<-18:36:44,pv,1,0
Rx<-18:36:44,pv,0,0
Rx<-18:51:41,tv,22.0;;;;;
Rx<-18:56:18,pv,1,1
Rx<-18:56:18,pv,1,0
Rx<-18:56:18,pv,1,1
Rx<-18:56:18,pv,1,0
Rx<-18:56:18,pv,1,1
Rx<-18:56:19,pv,1,0
Rx<-18:56:19,pv,1,1
Rx<-18:56:19,pv,1,0
Rx<-18:56:47,pv,1,1
Rx<-18:56:47,pv,1,0
Rx<-18:56:47,pv,1,1
Rx<-18:56:47,pv,0,1
Rx<-18:56:47,pv,1,0
Rx<-18:56:47,pv,0,0
Rx<-18:56:47,pv,1,1
Rx<-18:56:47,pv,0,1
Rx<-18:56:47,pv,0,0
Rx<-18:56:47,pv,0,1
Rx<-18:56:47,pv,1,0
Rx<-18:56:47,pv,0,0
Rx<-19:25:05,pv,0,1
Rx<-19:25:05,pv,0,0
Rx<-19:25:05,pv,0,1
Rx<-19:25:05,pv,0,0
Rx<-19:25:05,pv,0,1
Rx<-19:25:05,pv,1,1
Rx<-19:25:05,pv,0,0
Rx<-19:25:05,pv,1,0
Rx<-19:27:08,pv,1,1
Rx<-19:27:09,pv,1,0
Rx<-19:27:09,pv,1,1
Rx<-19:27:09,pv,0,1
Rx<-19:27:09,pv,1,0
Rx<-19:27:09,pv,1,1
Rx<-19:27:09,pv,0,0
Rx<-19:27:09,pv,0,1
Rx<-19:27:09,pv,1,0
Rx<-19:27:09,pv,0,0
Rx<-19:32:26,pv,0,1
Rx<-19:32:26,pv,1,1
Rx<-19:32:26,pv,0,0
Rx<-19:32:26,pv,1,0
Rx<-19:32:57,pv,1,1
Rx<-19:32:57,pv,1,0
Rx<-19:32:57,pv,1,1
Rx<-19:32:57,pv,1,0
Rx<-19:32:57,pv,1,1
Rx<-19:32:57,pv,1,0
Rx<-19:32:57,pv,1,1
Rx<-19:32:57,pv,1,0
Rx<-19:32:59,pv,1,1
Rx<-19:32:59,pv,0,1
Rx<-19:32:59,pv,0,0
Rx<-19:32:59,pv,0,1
Rx<-19:32:59,pv,1,0
Rx<-19:33:00,pv,0,0
Rx<-19:33:22,pv,1,1
Rx<-19:33:22,pv,1,0
Rx<-19:33:22,pv,1,1
Rx<-19:33:22,pv,0,1
Rx<-19:33:22,pv,0,0
Rx<-19:33:22,pv,0,1
Rx<-19:33:22,pv,1,0
Rx<-19:33:22,pv,0,0
Rx<-19:33:46,pv,0,1
Rx<-19:33:46,pv,1,1
Rx<-19:33:46,pv,0,0
Rx<-19:33:46,pv,1,0
Rx<-19:45:27,tv,22.0;;;;;
Rx<-19:49:08,pv,0,1
Rx<-19:49:08,pv,0,0
Rx<-19:49:08,pv,0,1
Rx<-19:49:08,pv,1,1
Rx<-19:49:08,pv,0,0
Rx<-19:49:08,pv,1,0
Rx<-19:49:24,pv,1,1
Rx<-19:49:24,pv,1,0
Rx<-19:49:24,pv,1,1
Rx<-19:49:24,pv,0,1
Rx<-19:49:24,pv,1,0
Rx<-19:49:24,pv,0,0
Rx<-19:59:33,pv,1,1
Rx<-19:59:33,pv,0,1
Rx<-19:59:33,pv,1,0
Rx<-19:59:33,pv,0,0
Rx<-19:59:33,pv,0,1
Rx<-19:59:33,pv,1,1
Rx<-19:59:33,pv,1,0
Rx<-19:59:33,pv,1,1
Rx<-19:59:33,pv,0,0
Rx<-19:59:33,pv,1,0
Rx<-19:59:33,pv,1,1
Rx<-19:59:33,pv,0,1
Rx<-19:59:33,pv,0,0
Rx<-19:59:33,pv,0,1
Rx<-19:59:33,pv,1,0
Rx<-19:59:33,pv,1,1
Rx<-19:59:33,pv,1,0
Rx<-19:59:33,pv,1,1
Rx<-19:59:33,pv,1,0
Rx<-19:59:33,pv,0,0
Rx<-20:39:12,tv,21.5;;;;;
Rx<-20:51:29,pv,0,1
Rx<-20:51:29,pv,1,1
Rx<-20:51:29,pv,1,0
Rx<-20:51:29,pv,1,1
Rx<-20:51:29,pv,1,0
Rx<-20:51:29,pv,0,0
Rx<-20:51:29,pv,1,1
Rx<-20:51:29,pv,0,1
Rx<-20:51:29,pv,1,0
Rx<-20:51:29,pv,0,0
Rx<-20:51:29,pv,0,1
Rx<-20:51:29,pv,1,1
Rx<-20:51:29,pv,0,0
Rx<-20:51:29,pv,1,0
Rx<-20:58:57,pv,1,1
Rx<-20:58:57,pv,1,0
Rx<-20:58:57,pv,1,1
Rx<-20:58:57,pv,1,0
Rx<-20:58:57,pv,1,1
Rx<-20:58:57,pv,0,1
Rx<-20:58:57,pv,1,0
Rx<-20:58:57,pv,0,0
Rx<-20:59:07,pv,0,1
Rx<-20:59:07,pv,1,1
Rx<-20:59:07,pv,0,0
Rx<-20:59:07,pv,1,0
Rx<-21:27:57,pv,0,1
Rx<-21:27:57,pv,1,1
Rx<-21:27:57,pv,0,0
Rx<-21:27:57,pv,0,1
Rx<-21:27:57,pv,0,0
Rx<-21:27:57,pv,0,1
Rx<-21:27:57,pv,0,0
Rx<-21:27:57,pv,0,1
Rx<-21:27:57,pv,0,0
Rx<-21:27:57,pv,1,0
Rx<-21:32:58,tv,21.0;;;;;
Rx<-22:26:43,tv,21.0;;;;;
Rx<-23:20:28,tv,21.0;;;;;

many thanks for the assistance so far.
cmpSmilie

Last edited by Scott; 02-24-2011 at 03:58 PM.. Reason: Code tags
# 6  
Old 02-24-2011
Quote:
Originally Posted by cmp260
I'm curious now, what shell would allow this to be achieved in 5 or 6 lines of code?
I didn't say the whole thing would be 5 lines, just that using some of BASH's extended features could make it shorter.
Quote:
Further to the solutions, I got something wrong see below,Smilie (I didn't have the data to hand when I wrote the question)
Hmmm. I take it I'm supposed to ignore the 'ev' and 'tv' lines?
Quote:
...and there are actually some complicating factors: the logger automatically stores the data in new directories each day, the dir name is the date (in the format 2011-01-31) but it is not stored in the line of text as I thought originally -sorry about that. Data is held in identical logfile.txt in each of the date directories but there is other data in the file that can be ignored.
Hmm... OK.
Quote:
If is is still even possible for the script to work properly, is there any way to run the script automatically on each of the directories in turn and append the date to the time of each transit? And even output a single file concatenating all the processed data?
Surely. I think you really will need a shell this time, though. Thank you for attaching the data, I'll see what I can do.
# 7  
Old 02-24-2011
yes, ignore those

correct, the ev and tv lines do not contribute to the bat counts (tv is temperature C.) In case you are interested, the loger is an "IPCAS USB-Input-Device"Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

I dont want to exit the program by ctrl + c

Hey , guys I am new to shell programing ,, so need a help from you guys ... I have to write a shell script that accepts file name or directory name from the user if it is a directory then throw an error if it is a file then give the user two options . 1.overwrite the content 2.append the... (2 Replies)
Discussion started by: coolashu
2 Replies

2. Shell Programming and Scripting

How can I get parent process program name?

Hi: I have 2 script on AIX server. The child script is called by parent script. For example: The parent script full name is /home/op/def/parent.spt, which calls /home/op/abc/child.spt I want to get the parent program name with full path name (i.e. /home/op/def/parent.spt), in... (3 Replies)
Discussion started by: cstsang
3 Replies

3. Shell Programming and Scripting

dont have a clue again- flying bat data new logger

hi, this is related to this thread https://www.unix.com/shell-programming-scripting/154822-dont-have-clue-program-use-process-flying-bat-data.html using another type of logger (ipcas ipether232) which produces csv data but not seperated into differnt folders. I need to work out how to get... (2 Replies)
Discussion started by: cmp260
2 Replies

4. UNIX for Dummies Questions & Answers

defunct process occuring in a particular program

All, I am getting a wired scenario, Not all times but some times i am getting the defunct process for a program. If i rerun the same program it is working fine.This defunct scenario is not occuring often. And this is happening only for the one program in my system that to sometimes Can you... (1 Reply)
Discussion started by: arunkumar_mca
1 Replies

5. Programming

Process creation in Unix with C Program

Hi, can somebody please help me regarding this? How can i print parent's PID from child's and vice versa. I have tried with getpid() & ngetppid() function but it is not giving me the correct data. The logic i used is: if (pid == 0) { getpid() : Chil'd PID getppid():... (1 Reply)
Discussion started by: dsudipta
1 Replies

6. Programming

How to start a process in linux using C program??

I have a set of attributes such as group id,group name,etc related to a linux process. Iwant to know how to start a process in linux using C program.Plz do help me. (3 Replies)
Discussion started by: vigneshinbox
3 Replies

7. Programming

Getting process info in a program

Hi, I am wondering if there is a way to find out in a C software program if a particular process is running without having to write a file. In the past, I have been using the system command to execute a pgrep and output the info to a file. Then the C program reads the file to make the... (1 Reply)
Discussion started by: herbmiller
1 Replies

8. HP-UX

get program name give a process id

Hi , I have query regarding to get a program name given a pid in HP-Ux . give procees id ( PID) i would like to retrieve the process/program through a C program ? my input to c program will be will be pid and i would like to know what is process name /program name . Many Thanks ... (1 Reply)
Discussion started by: naren_chella
1 Replies

9. HP-UX

IO by Process/program

HI there, I'm trying to find a way of showing the IO's performed by individual programs. Number of reads/writes IO time that kind of thing. Anybody know of any way to show this information. Free little downloads that kind of thing? Cheers Phil (2 Replies)
Discussion started by: cpiuk
2 Replies
Login or Register to Ask a Question