'Example' object has no attribute 'text_x' - Failing during Vocab Creation

Hello All,

I am reading from a CSV file but then during Vocab creation it is failing although I see that column is present into my CSV file. I have further looked into my data after reading from CSV file and i can see the columns properly as shared below.

Can anyone please guide me why this is failing durinh vocab creation by TWEET.build_vocab(train_ds)?

{‘text_x’: [’@tmobilehelp’, ‘I’, ‘think’, ‘there’, “'s”, ‘an’, ‘issue’, ‘in’, ‘my’, ‘area’, ‘accessing’, ‘data’, ‘from’, ‘Apple’, “'s”, ‘Podcast’, ‘both’, ‘streaming’, ‘and’, ‘downloads’, ‘over’, ‘LTE’, ‘.’, ‘Please’, ‘inspect’, ‘.’], ‘text_y’: [’@351818’, ‘Hey’, ‘Vincent’, ‘!’, ‘Shoot’, ‘me’, ‘a’, ‘DM’, ‘https://t-mo.io/2lJ0Kc1’, ‘so’, ‘I’, ‘can’, ‘take’, ‘a’, ‘closer’, ‘look’, ‘at’, ‘that’, ‘for’, ‘you’, ‘,’, ‘I’, ‘got’, ‘your’, ‘back’, ‘!’, '’, ‘VictorianLang’]}*

CSV File Structure

text_x text_y
Where the hell is nickelodean and MTV @Ask_Spectrum @368438 Thank you for reaching out. I am sorry your channels are missing. Can you please DM the account number or the pho… https://goo.gl/veJK1t

Code which is reading from CSV file:
TWEET = data.Field(sequential = True, tokenize = ‘spacy’, batch_first =True, include_lengths=True)

RESPONSE = data.Field(tokenize =‘spacy’,sequential = True, batch_first =True,include_lengths=True)

fields = [(‘text_x’, TWEET), (‘text_y’, RESPONSE)]
train_ds, valid_ds = data.TabularDataset.splits(
path = ‘data’,
train = ‘Tweet_train.csv’,
validation = ‘Tweet_valid.csv’,
format = ‘csv’,
fields = fields,
skip_header = True
Code which is failing

AttributeError Traceback (most recent call last)
in ()
1 # Before creating iterators of the Datasets we need to build the vocabulary for each Field object:
----> 2 TWEET.build_vocab(train_ds)
3 RESPONSE.build_vocab(train_ds)

1 frames
/usr/local/lib/python3.6/dist-packages/torchtext/data/dataset.py in getattr(self, attr)
152 if attr in self.fields:
153 for x in self.examples:
–> 154 yield getattr(x, attr)
156 @classmethod

AttributeError: ‘Example’ object has no attribute ‘text_x’