Skip to content

Instantly share code, notes, and snippets.

@anderzzz
Created June 8, 2023 10:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anderzzz/dcb747cbf768373f22c438edb791f3b4 to your computer and use it in GitHub Desktop.
Save anderzzz/dcb747cbf768373f22c438edb791f3b4 to your computer and use it in GitHub Desktop.
import pandas as pd
# Read the file and extract relevant lines based on the '#' symbol
with open('your_file_path') as file:
lines = file.readlines()
start_row = None
for i, line in enumerate(lines):
if line.startswith('# Data lines:'):
start_row = i + 2 # Skip two lines after the metadata line
break
# Read the file again, skipping the metadata lines dynamically
data = pd.read_csv('your_file_path', delimiter=';', skiprows=start_row)
# Preview the extracted data
print(data.head())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment