the idea is to write a python code reading data from a text file indicated below.
https://www.minorplanetcenter.net/iau/MPCORB/CometEls.txt
Further on, I would like to filter comet-data like name magnitude etc. etc.
Right now my problem is getting data output.
My code is:
import os.path
word_dict = {}
scriptpath = os.path.dirname(__file__)
filename = os.path.join(scriptpath, 'CometEls.txt','r')
for line in filename:
line = line.strip()
relation = line.split(' ')
word_dict[relation[0]] = relation[0:20]
while True:
word = input('Comet name : ')
if word in word_dict:
print ('Comets in list :' , word_dict[word])
print(filename) #show file location
else:
print( 'No comet data!')
print(word_dict) #show data from dictionary
As you can see data in my dictionary isn't the comet-data.
It should be
Typing in "a"
Theoretically the code works, the problem is creating the dictionary?
Maybe I'm completely wrong, but it doesn't work neither with tuples or lists, or it's better to copy data into a .csv file?
Best regards