Skip to content

Instantly share code, notes, and snippets.

@MindFlavor
Created March 7, 2016 11:30
Show Gist options
  • Save MindFlavor/0be2993f3e0a0fb4d8c7 to your computer and use it in GitHub Desktop.
Save MindFlavor/0be2993f3e0a0fb4d8c7 to your computer and use it in GitHub Desktop.
@stations =
EXTRACT SensorId int,
SensorType string,
Measure string,
StationId int,
StationName string,
Height int,
Province string,
City string,
Address string,
dontcare0 string,
dontcare1 string,
dontcare2 string,
dontcare3 string,
dontcare4 string
FROM "/user/mindflavor/Stazioni_Meteorologiche_noheader.csv"
USING Extractors.Csv();
@stat_milano_lambrate =
SELECT SensorId,
SensorType,
Measure,
StationId,
StationName,
Height,
Province,
City,
Address
FROM @stations
WHERE
City == "Milano"
AND StationName == "Milano - Lambrate"
AND SensorType == "Temperatura";
@events =
EXTRACT SensorId int,
Data DateTime,
Value float,
State string
FROM "/user/mindflavor/sensori_arpa_2015_noheader.csv"
USING Extractors.Csv();
@joined =
SELECT s.SensorId,
s.SensorType,
s.Measure,
s.StationId,
s.StationName,
s.Height,
s.Province,
s.City,
s.Address,
e.Data,
e.Value,
e.State
FROM @stat_milano_lambrate AS s
INNER JOIN
@events AS e
ON
e.SensorId == s.SensorId;
@projected =
SELECT Data,
Value
FROM @joined;
OUTPUT @projected
TO "/user/mindflavor/output/joined_mil_lamb.csv"
ORDER BY Data ASC
USING Outputters.Tsv();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment