我想要读取CSV文件后,条件动态跳过使用python.
条件-当我在CSV中发现6个COLS时,从那里读取,或者当我发现COL将序列命名为这6个COLS时.
File.csv
Col1,col2,col3
1,2,3
13,u,u
,,,
,,,
Col1,col2,col3,col4
1,2,3,4
13,u,u,y
,,,
,,,
Col1,col2,col3,col4,col5,col6
1,2,3,4,5,6
qw,ers,hh,yj,df,ji
现在我正在使用pandas.read_csv()
读取此文件
我知道在第10排我已经要求了COLS.
pandas.read_csv("file.csv", skiprows=10, header=None)
个
我想要动态跳过这一点,当我们跳过行时,当我们6,或者在这个序列COL1,COL2,COL3,COL4,COL5,COL6中的任何一个.
start = df.loc[df.FILE-START == 'col1,col2,col3,col4,col5,col6'].index[0]
df = pd.read_csv(filename, skiprows = start + 1)
我试过了,但没用.