csv data 在 google drive, 但 google colab 抓不到.
執行下列後, 出現 file not exist
import pandas as pd
df = pd.read_csv('test.csv')
print(df)
執行下列後, 跑不出結果
from google.colab import files
uploaded = files.upload()
import pandas as pd
import io
df = pd.read_csv(io.StringIO(uploaded['test.csv'].decode('utf-8')))
不須使用 io.StringIO,我寫了一小段程式,測試OK
#上載 2.csv
from google.colab import files
uploaded = files.upload()
for fn in uploaded.keys():
print('User uploaded file "{name}" with length {length} bytes'.format(
name=fn, length=len(uploaded[fn])))
# 確認 2.csv 是否已上載
!ls *.* -l
# use Pandas to read 2.csv
import pandas as pd
df = pd.read_csv('2.csv')
print(df)
from google.colab import files
import pandas as pd
files.upload() # 上傳檔案
print(files.os.listdir()) # 查看裡面有什麼檔案
pd.read_csv('test.csv') # 開啟已經上傳之檔案