How do I read CSV data into a record array in NumPy?

后端 未结 11 1464
广开言路
广开言路 2020-11-22 02:55

I wonder if there is a direct way to import the contents of a CSV file into a record array, much in the way that R\'s read.table(), read.delim(), a

11条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-22 03:58

    This work as a charm...

    import csv
    with open("data.csv", 'r') as f:
        data = list(csv.reader(f, delimiter=";"))
    
    import numpy as np
    data = np.array(data, dtype=np.float)
    

提交回复
热议问题