I have a text file containing this data and I need to make a function wherein this .txt file is opened, each line is read and then transferred into a python dictionary. This dictionary will have the first columns as keys and then the corresponding values would be both "Northings, Eastings".
Station Northings Eastings 1 10001.00 10001.00 2 10070.09 10004.57 3 10105.80 10001.70 So far this is the only thing I have and it has this error when the function is called AttributeError: 'builtin_function_or_method' object has no attribute 'split'. Sorry I'm quite new to this.
def parsefile(file_name): station = [] norths = [] easts = [] dict_station = {} with open(file_name) as fn: for line in fn: (stat,north,east) = line.split() stat.append(stat) norths.append(north) easts.append(east) dict_station[stat] = (north,east) print(station, norths, easts) return dict_station https://stackoverflow.com/questions/66791938/creating-a-function-that-opens-a-file-and-extracts-data-to-make-a-dictionary March 25, 2021 at 09:50AM
没有评论:
发表评论