我将iris.txt存储在我的云端硬盘/ ML的Google云端硬盘中,我试图打开并阅读它。
import csv
import numpy
file = open(r"/drive/ML/iris.txt")
mylist = list(csv.reader(file))
lines = numpy.asarray(mylist)
返回错误,我该怎么办?
IOErrorTraceback (most recent call last)
<ipython-input-27-5be95fc15074> in <module>()
6 from sklearn.cluster import KMeans
7
----> 8 file = open(r"/my drive/ML/iris.txt")
9 mylist = list(csv.reader(file))
10 lines = numpy.asarray(mylist)
IOError: [Errno 2] No such file or directory: '/my drive/ML/iris.txt'
答案 0 :(得分:0)
使用此:
from `google.colab` import files
uploaded = files.upload()
import io
df2 = pd.read_csv(io.BytesIO(uploaded['ex1data1.csv']))
答案 1 :(得分:0)
from google.colab import files
uploaded = files.upload()
for f in uploaded.keys():
file = open(f, 'r')
lines = file.readlines()