Skip to content

Instantly share code, notes, and snippets.

@MarkusOstermayer
Created November 3, 2020 20:13
Show Gist options
  • Save MarkusOstermayer/505a828a6d14f03920d2ebffb4fa0e88 to your computer and use it in GitHub Desktop.
Save MarkusOstermayer/505a828a6d14f03920d2ebffb4fa0e88 to your computer and use it in GitHub Desktop.
import csv
import os
def main():
'''Main Methode of the analysis-tool'''
data_path = "data/sensors"
for sensor in os.listdir(data_path):
print(f"Sensorame {sensor}")
# Create sets for probing
sensor_lat = set()
sensor_long = set()
sensor_location = set()
# iterate over the sensors
for data in os.listdir("/".join([data_path, sensor])):
filename = "/".join([data_path, sensor, data])
# read each file and perform a brute-force search
with open(filename, "r") as file:
data_reader = csv.reader(file, delimiter=';')
# skip the csv-header
next(data_reader)
# probe the known sets
for row in data_reader:
if(row[2] not in sensor_location):
sensor_location.add(row[2])
print(filename)
if(row[3] not in sensor_lat):
sensor_lat.add(row[3])
print(filename)
if(row[4] not in sensor_long):
sensor_long.add(row[4])
print(filename)
# Print the results to cout
print(f"{sensor}|"
f"Lat: {sensor_lat}|"
f"Lon: {sensor_long}|"
f"Location: {sensor_location}")
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment