简体   繁体   English

如何在 google colab 中读取.csv 文件?

[英]how can read .csv file in google colab?

I try to read the dataset in CSV format in google colab.我尝试在 google colab 中读取 CSV 格式的数据集。 when I ran this code, it took a lot of time and it hasn't stopped running yet to show the result of running the code.当我运行这段代码时,它花了很多时间,它还没有停止运行,还没有显示运行代码的结果。 How can I fix it?我该如何解决? Thank you for your consideration.谢谢您的考虑。 here is my code in python.这是我在 python 中的代码。

import pandas as pd
from google.colab import files
uploaded = files.upload()
with open('dataset.csv', 'r') as data:
    df3 = pd.read_csv('data', encoding = ('ansi'))
    print (df3)

here is the link of dataset: enter link description here这是数据集的链接: 在此处输入链接描述

remove the quotes,because there it is a variable which holds the value as dataset.csv so you don't need to mention quotes there.删除引号,因为它是一个将值保存为 dataset.csv 的变量,因此您无需在此处提及引号。

data is a variable, you need to use it as such data是一个变量,你需要这样使用它

import pandas as pd
from google.colab import files
uploaded = files.upload()
with open('dataset.csv', 'r') as data:
    df3 = pd.read_csv(data, encoding = ('ansi'))
    print (df3)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM