forked from earthobservations/wetterdienst
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Emit dataframe to different data sinks
- Export dataframe to different data sinks like SQLite, DuckDB, InfluxDB and CrateDB - Query results with SQL, based on in-memory DuckDB - Many features from cli.py now available through io.py - Tests for cli.py, run.py and io.py
- Loading branch information
Showing
17 changed files
with
1,614 additions
and
691 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 |
---|---|---|
|
@@ -7,7 +7,5 @@ source = | |
show_missing = true | ||
fail_under = 0 | ||
omit = | ||
wetterdienst/cli.py | ||
wetterdienst/run.py | ||
tests/* | ||
noxfile.py |
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
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
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
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,54 @@ | ||
""" | ||
===== | ||
About | ||
===== | ||
Acquire measurement information from DWD and filter using SQL. | ||
===== | ||
Setup | ||
===== | ||
:: | ||
pip install wetterdienst[sql] | ||
""" | ||
import logging | ||
|
||
from wetterdienst import DWDStationRequest, DataPackage | ||
from wetterdienst import Parameter, PeriodType, TimeResolution | ||
|
||
log = logging.getLogger() | ||
|
||
|
||
def sql_example(): | ||
|
||
request = DWDStationRequest( | ||
station_ids=[1048], | ||
parameter=[Parameter.TEMPERATURE_AIR], | ||
time_resolution=TimeResolution.HOURLY, | ||
start_date="2019-01-01", | ||
end_date="2020-01-01", | ||
tidy_data=True, | ||
humanize_column_names=True, | ||
prefer_local=True, | ||
write_file=True, | ||
) | ||
|
||
sql = "SELECT * FROM data WHERE element='temperature_air_200' AND value < -7.0;" | ||
log.info(f"Invoking SQL query '{sql}'") | ||
|
||
data = DataPackage(request=request) | ||
data.lowercase_fieldnames() | ||
df = data.filter_by_sql(sql) | ||
|
||
print(df) | ||
|
||
|
||
def main(): | ||
logging.basicConfig(level=logging.INFO) | ||
sql_example() | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
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.