Building list of lists from CSV file

前端 未结 3 848
不思量自难忘°
不思量自难忘° 2021-01-11 13:42

I have an Excel file(that I am exporting as a csv) that I want to parse, but I am having trouble with finding the best way to do it. The csv is a list of computers in my net

3条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-11 14:11

    This is how I opened a .csv file and imported columns of data as numpy arrays - naturally, you don't need numpy arrays, but...

    data = {}
    
    app = QApplication( sys.argv )
    fname = unicode ( QFileDialog.getOpenFileName() )
    app.quit()
    filename = fname.strip('.csv') + ' for release.csv'
    
    #open the file and skip the first two rows of data
    imported_array = np.loadtxt(fname, delimiter=',', skiprows = 2)
    
    data = {'time_s':imported_array[:,0]}
    data['Speed_RPM'] = imported_array[:,1]
    

提交回复
热议问题