<?php
// your code goes here<?php
//Set Dates
$fromDateTime = new DateTime('Wed, Sep 19 2018 00:00:00');
$toDateTime = new DateTime('Wed, Sep 19 2018 17:00:00');
// Load File
//$file = file_get_contents('Reject.txt');
$file = 'City Siren FCT_Tester #1 10039273
Date: 160518, Version: 1.00
ID Test Min Max Unit
1 Battery level 2.85 3.40 V
2 Piezo sound level 1.45 2.80 V
3 Left D3 (Ch 3) light intensity 2000 10000 mcd
4 Right D2 (Ch 1) light intensity 2000 10000 mcd
Date Time Battery level Piezo sound level Left D3 (Ch 3) light intensity Right D2 (Ch 1) light intensity
Wed, Sep 19 2018 00:25:55 3.385 0.000
Wed, Sep 19 2018 00:30:12 3.358 0.000
Wed, Sep 19 2018 00:31:15 3.240 0.000
Wed, Sep 19 2018 00:34:12 3.144 0.000
Wed, Sep 19 2018 01:08:49 3.376 0.000
Wed, Sep 19 2018 01:21:13 3.381 0.000
Wed, Sep 19 2018 01:31:05 3.362 1.600 10133.000
Wed, Sep 19 2018 02:03:10 3.379 1.600 10080.000
Wed, Sep 19 2018 03:43:48 3.374 1.652 10143.000
Wed, Sep 19 2018 04:04:24 3.372 1.589 10329.000
Wed, Sep 19 2018 04:05:29 3.376 1.586 10112.000
Wed, Sep 19 2018 04:15:04 3.175 0.000
Wed, Sep 19 2018 04:16:02 3.267 0.000
Wed, Sep 19 2018 04:16:18 3.377 0.000
Wed, Sep 19 2018 04:18:55 3.240 0.000
Wed, Sep 19 2018 04:21:40 3.371 1.600 10118.000
Wed, Sep 19 2018 04:24:18 3.379 1.604 10080.000
Wed, Sep 19 2018 04:24:48 0.414
Wed, Sep 19 2018 04:26:54 3.369 1.607 10035.000
Wed, Sep 19 2018 04:28:06 3.169 0.000
Wed, Sep 19 2018 04:31:46 3.204 0.000
Wed, Sep 19 2018 04:33:03 3.246 0.000
Wed, Sep 19 2018 04:36:45 3.164 0.000
Wed, Sep 19 2018 05:12:30 3.375 0.000
Wed, Sep 19 2018 05:18:29 3.380 0.000
Wed, Sep 19 2018 05:27:34 3.370 0.000
Wed, Sep 19 2018 05:33:23 3.299 0.000
Wed, Sep 19 2018 05:33:41 3.263 0.000
Wed, Sep 19 2018 05:34:00 3.233 0.000
Wed, Sep 19 2018 05:48:38 3.322 0.000
Wed, Sep 19 2018 06:03:40 3.368 1.624 10050.000
Wed, Sep 19 2018 08:13:09 3.378 0.000
Wed, Sep 19 2018 08:13:44 3.376 0.000
Wed, Sep 19 2018 08:18:37 3.269 0.000
Wed, Sep 19 2018 08:19:10 3.202 0.000
Wed, Sep 19 2018 08:24:20 3.383 0.000
Wed, Sep 19 2018 08:35:43 3.368 1.613 10355.000
Wed, Sep 19 2018 08:48:31 3.373 1.620 10246.000
Wed, Sep 19 2018 08:54:07 0.414
Wed, Sep 19 2018 08:55:54 3.368 0.000
Wed, Sep 19 2018 09:02:55 3.370 0.000
Wed, Sep 19 2018 09:03:09 3.379 0.000
Wed, Sep 19 2018 09:06:55 3.375 1.614 10280.000
Wed, Sep 19 2018 09:15:12 3.379 1.618 10115.000
Wed, Sep 19 2018 09:16:23 3.377 0.000
Wed, Sep 19 2018 09:21:27 3.372 1.586 10022.000
Wed, Sep 19 2018 09:23:50 3.377 0.000
Wed, Sep 19 2018 10:07:47 3.283 0.000
Wed, Sep 19 2018 10:12:17 3.048 0.000
Wed, Sep 19 2018 10:13:08 3.330 0.000
Wed, Sep 19 2018 10:18:00 3.371 0.000
Wed, Sep 19 2018 10:46:43 3.376 1.617 10437.000
Wed, Sep 19 2018 10:59:51 3.369 0.000
Wed, Sep 19 2018 11:01:43 3.379 1.591 10366.000
Wed, Sep 19 2018 11:02:26 3.372 0.000
Wed, Sep 19 2018 11:13:09 3.230 0.000
Wed, Sep 19 2018 11:29:12 3.379 0.000
Wed, Sep 19 2018 11:39:50 3.367 1.609 10019.000
Wed, Sep 19 2018 11:57:41 3.319 0.000
Wed, Sep 19 2018 12:04:41 3.358 1.617 10038.000
Wed, Sep 19 2018 12:10:37 3.372 0.000
Wed, Sep 19 2018 12:14:46 3.290 0.000
Wed, Sep 19 2018 12:18:51 3.371 0.000
Wed, Sep 19 2018 12:24:13 3.278 0.000
Wed, Sep 19 2018 12:25:26 3.158 0.000
Wed, Sep 19 2018 12:41:07 3.310 0.000
Wed, Sep 19 2018 13:05:04 3.371 1.610 10051.000
Wed, Sep 19 2018 13:48:05 3.371 1.612 10004.000
Wed, Sep 19 2018 14:02:24 3.188 0.000
Wed, Sep 19 2018 14:09:02 3.085 0.000
Wed, Sep 19 2018 15:28:01 3.034 0.000
Wed, Sep 19 2018 14:44:12 3.374 1.609 10034.000
Wed, Sep 19 2018 14:47:27 2.838
Wed, Sep 19 2018 14:51:29 3.377 1.615 10157.000
Wed, Sep 19 2018 15:01:32 3.365 0.000
Wed, Sep 19 2018 15:01:48 3.372 1.626 10115.000
Wed, Sep 19 2018 15:06:46 2.778
Wed, Sep 19 2018 15:11:57 3.374 1.612 10304.000
Wed, Sep 19 2018 15:17:34 2.826
Wed, Sep 19 2018 15:38:00 3.328 0.000
Wed, Sep 19 2018 16:16:05 3.332 0.000
Wed, Sep 19 2018 16:26:48 3.376 1.586 9477.500 0.000
Wed, Sep 19 2018 16:33:26 3.374 1.619 10115.000
Wed, Sep 19 2018 16:58:37 3.378 1.614 10206.000 ';
// Split by lines
// counter
$rowsintimespan = 0;
$rowswithbattery = 0;
$rowswithpiezo = 0;
$rowswithright = 0;
$rowswithleft = 0;
// Do Line-By-Line starting by Line 16 (Array Index 15)
for($i = 11; $i < count($lines); $i++) { // the file is "Tue,<space>Sep<space>18<space><space>2018<tab>23:59:53<tab>"
$dateobj = DateTime::createFromFormat("???, M d Y?H:i:s+", $lines[$i]);
// check if date is in your Timespan
if($dateobj < $toDateTime && $dateobj > $fromDateTime) {
$rowsintimespan++; // count if in timespan
// 0 = Date, 1 = Time, 2 = Battery Level, 3 = Piezo, 4 = left, 5 = Right
// Count Battery-Values
$rowswithbattery++;
}
$rowswithpiezo++;
}
$rowswithleft++;
}
$rowswithright++;
}
}
}
// Debug-Output
echo 'In Timespan: '.$rowsintimespan."\n";
echo 'Rows With Battery: '.$rowswithbattery."\n";
echo 'Rows With Piezo: '.$rowswithpiezo."\n";
echo 'Rows With Left: '.$rowswithleft."\n";
echo 'Rows With Rigth: '.$rowswithright."\n";
?>