# Parse\_data\_from\_file

**URL:** <https://community.deeplearning.ai/t/parse-data-from-file/190087>\
**Category:** Natural Language Processing in TensorFlow\
**Tags:** week-module-1\
**Created:** [August 21, 2022, 4:23pm UTC](https://community.deeplearning.ai/t/parse-data-from-file/190087 "2022-08-21T16:23:45Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![SURENDRA\_SRINIVAS](https://avatars.discourse-cdn.com/v4/letter/s/db5fbb/32.png) [@SURENDRA\_SRINIVAS](https://community.deeplearning.ai/u/SURENDRA_SRINIVAS)\
**Post date:** [August 21, 2022, 4:23pm UTC](https://community.deeplearning.ai/t/parse-data-from-file/190087/1 "2022-08-21T16:23:45Z")

</div>

![Screenshot 2022-08-21 at 21.50.13](https://global.discourse-cdn.com/dlai/original/3X/b/3/b3045c065a4ea6e887c9a41fa0f36a7ccae42e31.png)

How to proceed with this ?

---

<div class="post-metadata">

**Author:** ![balaji.ambresh](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/balaji.ambresh/32/128697_2.png) [@balaji.ambresh](https://community.deeplearning.ai/u/balaji.ambresh)\
**Post date:** [August 21, 2022, 6:20pm UTC](https://community.deeplearning.ai/t/parse-data-from-file/190087/2 "2022-08-21T18:20:10Z")

</div>

Please ask specific questions about the assignment rather than generic questions like how to implement a full graded function. It would help if you go through the markdown cells and lectures prior to posting such questions. They provide good context on what should be done as part of parsing an input csv file.

---

<div class="post-metadata">

**Author:** ![SURENDRA\_SRINIVAS](https://avatars.discourse-cdn.com/v4/letter/s/db5fbb/32.png) [@SURENDRA\_SRINIVAS](https://community.deeplearning.ai/u/SURENDRA_SRINIVAS)\
**Post date:** [August 21, 2022, 7:25pm UTC](https://community.deeplearning.ai/t/parse-data-from-file/190087/3 "2022-08-21T19:25:02Z")

</div>

Thanks for the information, I have gone through the markdown cells, but i couldn’t figure out what to code in this function. And it was not taught in the lectures …

---

<div class="post-metadata">

**Author:** ![balaji.ambresh](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/balaji.ambresh/32/128697_2.png) [@balaji.ambresh](https://community.deeplearning.ai/u/balaji.ambresh)\
**Post date:** [August 22, 2022, 9:06am UTC](https://community.deeplearning.ai/t/parse-data-from-file/190087/4 "2022-08-22T09:06:14Z")

</div>

I’ve asked on the mentor forum for a mentor / staff to help you from scratch and improve the assignment.  
Good luck.

---

<div class="post-metadata">

**Author:** ![SURENDRA\_SRINIVAS](https://avatars.discourse-cdn.com/v4/letter/s/db5fbb/32.png) [@SURENDRA\_SRINIVAS](https://community.deeplearning.ai/u/SURENDRA_SRINIVAS)\
**Post date:** [August 22, 2022, 11:13am UTC](https://community.deeplearning.ai/t/parse-data-from-file/190087/5 "2022-08-22T11:13:56Z")

</div>

where will i be contacted by the mentor ?

---

<div class="post-metadata">

**Author:** ![balaji.ambresh](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/balaji.ambresh/32/128697_2.png) [@balaji.ambresh](https://community.deeplearning.ai/u/balaji.ambresh)\
**Post date:** [August 22, 2022, 11:56am UTC](https://community.deeplearning.ai/t/parse-data-from-file/190087/6 "2022-08-22T11:56:18Z")

</div>

If you don’t hear within 48 hours, please ping me on this thread. I’ll assume help you from scratch.

---

<div class="post-metadata">

**Author:** ![SURENDRA\_SRINIVAS](https://avatars.discourse-cdn.com/v4/letter/s/db5fbb/32.png) [@SURENDRA\_SRINIVAS](https://community.deeplearning.ai/u/SURENDRA_SRINIVAS)\
**Post date:** [August 24, 2022, 3:42pm UTC](https://community.deeplearning.ai/t/parse-data-from-file/190087/7 "2022-08-24T15:42:17Z")

</div>

I just want to let you know that, I was not contacted by anyone.

---

<div class="post-metadata">

**Author:** ![balaji.ambresh](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/balaji.ambresh/32/128697_2.png) [@balaji.ambresh](https://community.deeplearning.ai/u/balaji.ambresh)\
**Post date:** [August 24, 2022, 5:20pm UTC](https://community.deeplearning.ai/t/parse-data-from-file/190087/8 "2022-08-24T17:20:02Z")

</div>

The file `bbc-text.csv` consists of 2 columns:

1. The 1st column is called `category` which is the label associated with an article. Here are a few labels: `'tech', 'business', 'sport', 'sport', 'entertainment'`
2. The 2nd column is called `text` which contains the actual news article.

Your model should be able to predict the label associated with a news article.

From the perspective of multi-class classficiation problem like this one, stopwords don’t contribute much towards model performance (i.e. classification accuracy). So, they can be removed.

`parse_data_from_file`

1. This function is responsible for reading data for further processing. Here, `sentences` are going to processed further to bocome model inputs and `labels` are the class labels.
2. For each row in the csv file:  
a. Read each row in the csv file.  
b. Remove stopwords from `text` column and then add it to `sentences` list.  
c. Add `category` to the `labels` list.
3. Return `sentences` and `labels` from the function.

Sentences and labels are converted to numbers for use as input / output to the model. So, use a tokenizer to fit and transform data.

With this information, please take a crack at the assignment. Reply to this thread with clarifications you need.

---

<div class="post-metadata">

**Author:** ![Sumit1](https://avatars.discourse-cdn.com/v4/letter/s/aeb1de/32.png) [@Sumit1](https://community.deeplearning.ai/u/Sumit1)\
**Post date:** [August 27, 2022, 10:39am UTC](https://community.deeplearning.ai/t/parse-data-from-file/190087/9 "2022-08-27T10:39:45Z")

</div>

Can you please highlight the error in notebook why i am getting different figures in miniature dataset ?  
Notebook attached

Thanks in advance

ORIGINAL DATASET:

There are 2225 sentences in the dataset.

First sentence has 436 words (after removing stopwords).

There are 2225 labels in the dataset.

The first 5 labels are [‘tech’, ‘business’, ‘sport’, ‘sport’, ‘entertainment’]

MINIATURE DATASET:

There are 2225 sentences in the miniature dataset.

First sentence has 436 words (after removing stopwords).

There are 2225 labels in the miniature dataset.

The first 5 labels are [‘tech’, ‘business’, ‘sport’, ‘sport’, ‘entertainment’]

_ **Expected Output:** _

```auto
ORIGINAL DATASET:

There are 2225 sentences in the dataset.

First sentence has 436 words (after removing stopwords).

There are 2225 labels in the dataset.

The first 5 labels are ['tech', 'business', 'sport', 'sport', 'entertainment']

MINIATURE DATASET:

There are 5 sentences in the miniature dataset.

First sentence has 436 words (after removing stopwords).

There are 5 labels in the miniature dataset.

The first 5 labels are ['tech', 'business', 'sport', 'sport', 'entertainment']

```

[code removed - moderator]

---

<div class="post-metadata">

**Author:** ![balaji.ambresh](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/balaji.ambresh/32/128697_2.png) [@balaji.ambresh](https://community.deeplearning.ai/u/balaji.ambresh)\
**Post date:** [August 27, 2022, 10:55am UTC](https://community.deeplearning.ai/t/parse-data-from-file/190087/10 "2022-08-27T10:55:01Z")

</div>

@Sumit1

You are hardcoding the path to `"./data/bbc-text.csv"` instead of using the function parameter `filename`.
