[Python] How to open txt on Google Colab?

Discussão em 'Python' iniciado por Stack, Novembro 20, 2024.

  1. Stack

    Stack Membro Participativo

    I have my iris.txt stored at my Google Drive at My Drive/ML, I was trying to open and read it.

    import csv
    import numpy

    file = open(r"/drive/ML/iris.txt")
    mylist = list(csv.reader(file))
    lines = numpy.asarray(mylist)


    It returned me the error, how should I do?

    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'

    Continue reading...

Compartilhe esta Página