-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
1,233 additions
and
259 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
foo |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<title>תלונות תחבורה ציבורית</title> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> | ||
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" | ||
integrity="sha512-puBpdR0798OZvTTbP4A8Ix/l+A4dHDD0DGqYW6RQ+9jxkRFclaxxQb/SJAWZfWAkuyeQUytO7+7N4QKrDh+drA==" | ||
crossorigin=""/> | ||
<script src="https://unpkg.com/[email protected]/dist/leaflet.js" | ||
integrity="sha512-nMMmRyTVoLYqjP9hrbed9S+FzjZHW5gY1TWCHA5ckwXZBadntCNs8kEqAWdrb9O7rxbCaA4lKTIWjDXZxflOcA==" | ||
crossorigin=""></script> | ||
|
||
<link rel="stylesheet" type="text/css" href="style.css"> | ||
</head> | ||
<body dir="rtl"> | ||
<div class="container"> | ||
<div class="jumbotron"> | ||
<h1>אתר תלונות תחבורה ציבורית</h1> | ||
<p>כאן תוכלו להתלונן על התנהלות של התחבורה הציבורית בישראל</p> | ||
</div> | ||
|
||
<div class="row"> | ||
<div id="mapid"></div> | ||
</div> | ||
<div class="row"> | ||
<div class="col-sm-4"> | ||
<h3>Column 1</h3> | ||
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit...</p> | ||
<p>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris...</p> | ||
</div> | ||
<div class="col-sm-4"> | ||
<h3>Column 2</h3> | ||
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit...</p> | ||
<p>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris...</p> | ||
</div> | ||
<div class="col-sm-4"> | ||
<h3>Column 3</h3> | ||
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit...</p> | ||
<p>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris...</p> | ||
</div> | ||
</div> | ||
</div> | ||
</body> | ||
<script src="script.js"></script> | ||
</html> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
var mymap = L.map('mapid').setView([32.073608, 34.790128], 18); | ||
|
||
mymap.scrollWheelZoom.disable(); | ||
|
||
// TODO: Create new `access_token` | ||
L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token=pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4NXVycTA2emYycXBndHRqcmZ3N3gifQ.rJcFIG214AriISLbB6B5aw', { | ||
maxZoom: 18, | ||
attribution: 'Map data © <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, ' + | ||
'<a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' + | ||
'Imagery © <a href="https://www.mapbox.com/">Mapbox</a>', | ||
id: 'mapbox.streets' | ||
}).addTo(mymap); | ||
|
||
L.marker([32.073539, 34.789106]).addTo(mymap); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#mapid { | ||
height: 400px; | ||
width: 100%; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
from glob import glob | ||
import os | ||
import pandas as pd | ||
import datetime | ||
import re | ||
from os.path import join | ||
|
||
def timestr_to_seconds(x, *, only_mins=False): | ||
try: | ||
hms = x.str.split(':', expand=True) | ||
if not only_mins: | ||
result = hms.iloc[:,0].astype(int) * 3600 + hms.iloc[:,1].astype(int) * 60 + hms.iloc[:,2].astype(int) | ||
else: | ||
result = hms.iloc[:,0].astype(int) * 3600 + hms.iloc[:,1].astype(int) * 60 | ||
except: | ||
result = np.nan | ||
|
||
return result | ||
|
||
def create_trip_df(path, drop=['timestamp', 'desc'], | ||
convert_timestr_to_seconds=True, add_date=True, | ||
add_trailing_zeros=True): | ||
header = ["timestamp", "desc", "agency_id", | ||
"route_id", "route_short_name", "service_id", | ||
"planned_start_time", "bus_id", "predicted_end_time", | ||
"time_recorded", "lat", "lon"] | ||
date = datetime.datetime.strptime(re.findall('siri_rt_data\\.([^\\.]+)\\.\\d+\\.log', path)[0], '%Y-%m-%d') | ||
df = pd.read_csv(path, header=None, error_bad_lines=False) | ||
df.columns = header | ||
if drop is not None: | ||
df = df.drop(drop, axis=1) | ||
df = (df.assign(agency_id = lambda x: x.agency_id.astype(int)) | ||
.assign(service_id = lambda x: x.service_id.astype(int)) | ||
.assign(route_id = lambda x: x.route_id.astype(int)) | ||
.assign(lat = lambda x: x.lat.astype(float)) | ||
.assign(lon = lambda x: x.lon.astype(float))) | ||
if convert_timestr_to_seconds: | ||
df = (df.assign(planned_start_time = lambda x: timestr_to_seconds(x.planned_start_time, only_mins=True)) | ||
.assign(predicted_end_time = lambda x: timestr_to_seconds(x.predicted_end_time, only_mins=True)) | ||
.assign(time_recorded = lambda x: timestr_to_seconds(x.time_recorded))) | ||
if add_date: | ||
df = (df.assign(date = date)) | ||
if add_trailing_zeros: | ||
df = (df | ||
.assign(planned_start_time = lambda x: x.planned_start_time+':00') | ||
.assign(predicted_end_time = lambda x: x.predicted_end_time+':00')) | ||
|
||
return df | ||
|
||
FOLDER = '<SIRI_LOGS_FOLDER>' | ||
out_folder = '<SPLUNK_SIRI_CSV_INPUTS_FOLDER>' | ||
if not os.path.exists(out_folder): | ||
os.mkdir(out_folder) | ||
|
||
for file in glob(FOLDER+'/*2019*.log.gz'): | ||
base = '.'.join(os.path.basename(file).split('.')[:-2]) | ||
out_path = os.path.join(out_folder, base+'.csv.gz') | ||
if not os.path.exists(out_path): | ||
#out_path = os.path.join(out_folder, base+'_FIXED.csv.gz') | ||
print(file) | ||
try: | ||
df = create_trip_df(file, drop=['desc'], convert_timestr_to_seconds=False) | ||
except Exception as e: | ||
print(str(e)) | ||
#df.to_parquet(bn + '.parq') | ||
#os.remove(file) | ||
df.to_csv(out_path, compression='gzip', index=False) |
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
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
Oops, something went wrong.