Python CSV reader to skip 9 headers

前端 未结 3 1578
伪装坚强ぢ
伪装坚强ぢ 2021-01-27 07:57
import os
import csv

def get_file_path(filename):
    currentdirpath = os.getcwd()
    file_path = os.path.join(os.getcwd(), filename)
    print(file_path)
    return(f         


        
3条回答
  •  伪装坚强ぢ
    2021-01-27 08:28

    If you are using numpy, have a look at the skip_header argument in genfromtxt (http://docs.scipy.org/doc/numpy/user/basics.io.genfromtxt.html )

    import numpy as np     
    r = np.genfromtxt(filepath, skip_header=9, names = ['account','amount'] , delimiter = ',')
    print(r.account[0],r.amount[0])
    

提交回复
热议问题