利用pandas库读取,转为numpy矩阵
注意读取csv文件时第一行数据默认不读,因此需要给csv加一行。
import numpy as np
import pandas as pd
def load_csv(path):
data_read = pd.read_csv(path)
list = data_read.values.tolist()
data = np.array(list)
print(data.shape)
# print(data)
return data
mat = load_csv("./point.csv")
print(mat)
运行结果