Created
June 8, 2023 13:02
-
-
Save anderzzz/01c6a157980cca24e0c9c476fde3d8d4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
metadata = {} | |
with open('your_file_path') as file: | |
lines = file.readlines() | |
for line in lines: | |
if line.startswith('# River:'): | |
metadata['river'] = line.split(':')[1].strip() | |
elif line.startswith('# Station:'): | |
metadata['station'] = line.split(':')[1].strip() | |
elif line.startswith('# Latitude (DD):'): | |
metadata['latitude'] = float(line.split(':')[1].strip()) | |
elif line.startswith('# Longitude (DD):'): | |
metadata['longitude'] = float(line.split(':')[1].strip()) | |
# Print the extracted metadata | |
for key, value in metadata.items(): | |
print(f"{key}: {value}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment