I am recently been using google collab juypter notebook. After Uploading the text file, unable to open the file using an open function in Python 3.
from google.colab import files
import io
uploaded = files.upload()
for fn in uploaded.keys():
print('User uploaded file "{name}" with length {length} bytes'.format(
name=fn, length=len(uploaded[fn])))
data_path = io.StringIO(uploaded['fra.txt'].decode('utf-8'))
with open(data_path, 'rb') as f:
lines = f.read().split('\n')
but it gives this error : TypeError: expected str, bytes, or os.PathLike object, not _io.StringIO
how to open a text file in google colab juypter notebook?
Change to just
data_path = 'fra.txt'
Should work.