Created
November 3, 2020 20:13
-
-
Save MarkusOstermayer/505a828a6d14f03920d2ebffb4fa0e88 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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