This commit is contained in:
Stefan Ritter 2023-04-05 22:04:03 +02:00
commit c5ca3cf428
2 changed files with 10603 additions and 0 deletions

36
alt.py Normal file
View File

@ -0,0 +1,36 @@
import sys
import csv
if len(sys.argv) < 4:
print('Syntax: ./alt.py $COUNTRY $CITY $VARIANCE')
sys.exit(0)
country = sys.argv[1]
city = sys.argv[2]
var = float(sys.argv[3])
data_file = open('data.csv')
data = csv.reader(data_file, delimiter=';', quotechar='"')
my_location = []
for item in data:
if item[1] == country:
if item[2] == city:
my_location = item
break
if my_location:
print('%s, %s has an altitude of %s' % (my_location[2], my_location[1], my_location[5]))
else:
print('Location not found in data!')
sys.exit(0)
my_altitude = float(my_location[5])
print("\n" + 'Here are the cities that share the same altitude with you:' + "\n")
for item in data:
if my_altitude - var < float(item[5]) and my_altitude + var > float(item[5]):
print('%s, %s has an altitude of %s' % (item[2], item[1], item[5]))
data_file.close()

10567
data.csv Normal file

File diff suppressed because it is too large Load Diff