I want to extract the first 4 lines from my file into a new string. In this file I have about 400 lines but only need the first 4. I wrote this code with the enumerate()
function so I can see the indices of the lines but now I am a little bit confused on how to do the next step.
filename = "data_00-000.raw.seq."
with open(filename, 'r') as fh:
file_content = fh.read().strip()
x = file_content.split('\n')
for value, zeile in enumerate(x, 0):
print (value, zeile)