EDIT . You can still use the struct module:
See the struct module documentation . It looks like you want to usestruct.unpack()
What you want is probably something like:
import struct
with open("filename.txt", "r") as f:
for line in f:
(coop_id, lat, lon, elev, state, name, c1, c2, c3, utc_offset
) = struct.unpack("6sx8sx9sx6sx2sx30sx6sx6sx6sx2s", line.strip())
(lat, lon, elev) = map(float, (lat, lon, elev))
utc_offset = int(utc_offset)
source
share