Parse data from file

I am trying to parse_data_from_file function. I think it asks me to select every sentence from the file and for every sentence exclude the stop words. Here is my code, it gives me the error:

Would you please take a look at my code?

[code removed - moderator]

I explained each line of code after it.

I also don’t quite get what the label is. is that sentence number?

would really appreciate your help.
Thank you.

I am not familiar with the assignment right now, but do you initialize the sentences as a list somewhere above!

The csv file consists of 2 columns. The label (category in the header) is in the 0th column and text is in 1st column.
As part of parsing the file, you should return a tuple of sentences and labels from the function.
For each row in the csv file:

  1. Add the label as is to the list of labels.
  2. Remove stopwords from the text and then add it to sentences.

The writeup in the assignment is detailed. If you’re having trouble with this, see the Expected Output section to see what the labels are.

Hi Balaji.ambresh,
Thank you. I understand it now.
So I am trying to append labels and sentences list, which are initialized by [ ], by each label and sentence (after removed stop words). But I encounter an error saying None type has no append method?

I have attached my code below for your convenience. I will delete it afterward.

Also, I wonder if the next() method–skipping the first row is right.
Would you please take a look again? Thank you.

Yes, sentences and labels are initialized by the assignment as brackets [ ].
Thank you for help.

I just figured out where I am wrong.
I should have just use sentences.append instead of sentences=sentencs.append()

Thank you anyway. I am deleting my code.

1 Like

Thats right, I also got this past me but good catch Fei!