Created
November 13, 2018 04:21
-
-
Save x011/a764ee4dab50158725a15180b9c948fa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* User: x | |
* Project: stack | |
* Time: 13-Nov-18 03:16 | |
*/ | |
/* set a default timezone? */ | |
date_default_timezone_set("America/New_York"); | |
$fromDateTime = new DateTime('2018-11-13 03:00:00'); # Y-m-d H:i:s | |
$toDateTime = new DateTime('2018-11-13 19:59:00'); | |
$x = file("https://www.dropbox.com/s/k72gi3exvluoa1n/reject_new.txt?dl=1"); | |
foreach (array_slice($x,11) as $line){ | |
$parts = explode("\t", $line); | |
$date = $parts[0]." ".$parts[1]; | |
$battery_level = (float)$parts[2]; | |
$piezzo_level = (float)$parts[3]; | |
if(!$battery_level){$battery_level=0.000;} | |
if(!$piezzo_level){$piezzo_level=0.000;} | |
print("$date $battery_level $piezzo_level\n"); | |
$dateobj = DateTime::createFromFormat("???,?M?d??Y?H:i:s", $date); | |
if ( $dateobj < $toDateTime && $dateobj > $fromDateTime ) { | |
# do something with the result | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment