Home > other >  Python sliding read CSV file
Python sliding read CSV file

Time:12-01

I have a CSV file list, for example,

See each row from the table data, I now want to operation is
Read 2-7 rows of data for the first time, a second read 3-8 rows of data, for the fourth time read 4-9 rows so on,
This algorithm is how to achieve

CodePudding user response:

So I can
 import pandas as pd 
Path=""
Df1=pd. Read_csv (path, nrows=6, the header=None, skiprows=1)
Print (df1)
Df1=pd. Read_csv (path, nrows=6, the header=None, skiprows=2)
Print (df1)
Df1=pd. Read_csv (path, nrows=6, the header=None, skiprows=3)
Print (df1)

CodePudding user response:

Yo ha ha ha, no, my CSV file a total of tens of thousands of lines, the first step must be to get the CSV file, the number of rows and then traverse 1-10 rows of data, and then traverse line 2-11, 3, 4-12-13,,,, is the effect of sliding window
  • Related