Skip to content

Commit

Permalink
#2: Improve readability
Browse files Browse the repository at this point in the history
  • Loading branch information
bednar committed Aug 9, 2019
1 parent fb813e9 commit 143ccf6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ def parse_row(row: OrderedDict):
"""
Converts vix-daily.csv into sequence of data point
"""
data = rx.from_iterable(DictReader(open('vix-daily.csv', 'r'))) \
data = rx \
.from_iterable(DictReader(open('vix-daily.csv', 'r'))) \
.pipe(ops.map(lambda row: parse_row(row)))

client = InfluxDBClient(url="http://localhost:9999/api/v2", token="my-token-123", org="my-org", debug=True)
Expand Down Expand Up @@ -257,7 +258,8 @@ def line_protocol(temperature):
"""
Read temperature every minute; distinct_until_changed - produce only if temperature change
"""
data = rx.interval(period=timedelta(seconds=60))\
data = rx\
.interval(period=timedelta(seconds=60))\
.pipe(ops.map(lambda t: sensor_temperature()),
ops.map(lambda temperature: line_protocol(temperature)),
ops.distinct_until_changed())
Expand Down
3 changes: 2 additions & 1 deletion influxdb2_test/import_data_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ def parse_row(row: OrderedDict):
"""
Converts vix-daily.csv into sequence of data point
"""
data = rx.from_iterable(DictReader(open('vix-daily.csv', 'r'))) \
data = rx \
.from_iterable(DictReader(open('vix-daily.csv', 'r'))) \
.pipe(ops.map(lambda row: parse_row(row)))

client = InfluxDBClient(url="http://localhost:9999/api/v2", token="my-token-123", org="my-org", debug=True)
Expand Down
3 changes: 2 additions & 1 deletion influxdb2_test/iot_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ def line_protocol(temperature):
"""
Read temperature every minute; distinct_until_changed - produce only if temperature change
"""
data = rx.interval(period=timedelta(seconds=60))\
data = rx\
.interval(period=timedelta(seconds=60))\
.pipe(ops.map(lambda t: sensor_temperature()),
ops.map(lambda temperature: line_protocol(temperature)),
ops.distinct_until_changed())
Expand Down

0 comments on commit 143ccf6

Please sign in to comment.