Notebook
# Open text file infile = open("myfile.dat", "r") # Read next line: line = infile.readline() # Read the lines in a loop one by one: for line in infile: <process line> # Load all lines into a list of strings: lines = infile.readlines() for line in lines: <process line>
21.8 18.1 19 23 26 17.8
Port: P060 Site: Avonmouth Latitude: 51.51089 Longitude: -2.71497 Start Date: 01JAN2012-00.00.00 End Date: 30APR2012-23.45.00 Contributor: National Oceanography Centre, Liverpool Datum information: The data refer to Admiralty Chart Datum (ACD) Parameter code: ASLVTD02 = Surface elevation (unspecified datum) of the water body by fixed in-situ pressure sensor
for key in dictionary: value = dictionary[key] print(value)
s[18] = '5' TypeError: "str" object does not support item assignment
t = delimiter.join(stringlist) stringlist = t.split(delimiter)
outfile.write(string)
outfile.write(string + ’\n’)