May-06-2022, 03:44 PM
If the file looks like this:
Whatever
114436
114474
114514
You can skip the first line in the file.
Whatever
114436
114474
114514
You can skip the first line in the file.
with open("data.csv", "r") as file: next(file) for line in file: print(int(line))
Output:114436
114474
114514
When using a contact manager (with), the file only remains open for code that is in the context block (indented 1 level deeper than the with). In your latest example the manhole_id file is closed before the for loop executes.