"no Such File" When Loading Csv Data Stored In G Drive To Torchtext Format Using Torchtext.data.tabulardataset,
I have stored a csv file in G drive and try to load it to torchtext data.TabularDataset. The error message is 'FileNotFoundError: [Errno 2] No such file or directory: 'https://....
Solution 1:
Let's assume you can afford to download this CSV file. I would suggest you to use a functionally built-in on torchtext: download_from_url
.
import os
import torch
from torchtext import data, datasets
from torchtext.utils import download_from_url
# download the file
CSV_FILENAME = 'data.csv'
CSV_GDRIVE_URL = 'https://drive.google.com/uc?export=download&id=1eWMjusU3H34m0uml5SdJvYX6gQuB8zta'
download_from_url(CSV_GDRIVE_URL, CSV_FILENAME)
TEXT = data.Field(tokenize = 'spacy', batch_first = True, lower=False) #from torchtext import data
LABEL = data.LabelField(sequential=False, dtype = torch.float)
# if you're on Colab, you'll need this /content
train = data.TabularDataset(path=os.path.join('/content', CSV_FILENAME),
format='csv',
fields = [('Insult', LABEL), (None, None), ('Comment', TEXT)],
skip_header=False )
Notice that the Google Drive link should not be the one with open?id
, but change it to uc?export=download&id
.
Post a Comment for ""no Such File" When Loading Csv Data Stored In G Drive To Torchtext Format Using Torchtext.data.tabulardataset,"