I have a very long file and I only need parts, a slice, of it. There is new data coming in so the file will potentially get longer.
To load the data from the CSV I u
Starting Numpy 1.10
, np.genfromtxt takes an optional parameter max_rows
which limits the number of lines to read.
Combined with the other optional parameter skip_header
, you can select a slice of your file (for instance lines 100 to 150):
import numpy as np
np.loadtxt('file.txt', skip_header=100, max_rows=50)