A file is, in particular, iterable (see Section 9.3: Iterable objects). Files iterate their lines:
with open(name,'r') as myfile: for line in myfile: data = line.split(';') print(f'time {data[0]} sec temperature {data[1]} C')
The lines of the file are returned as strings. The string method split is a possible tool to convert the string to a list of strings; for example:
data = 'aa;bb;cc;dd;ee;ff;gg' data.split(';') # ['aa', 'bb', 'cc', 'dd', 'ee', 'ff', 'gg'] data = 'aa bb cc dd ee ff gg' data.split(' ') # ['aa', 'bb', 'cc', 'dd', 'ee', 'ff', 'gg']
Since the object myfile is iterable, we can also do a direct extraction into a list, as follows:
data = list(myfile)