# Adding column from CSV into meta with custom loader

**URL:** <https://support.prodi.gy/t/adding-column-from-csv-into-meta-with-custom-loader/822>\
**Category:** Uncategorized\
**Tags:** usage, solved\
**Created:** [September 19, 2018, 1:11am UTC](https://support.prodi.gy/t/adding-column-from-csv-into-meta-with-custom-loader/822 "2018-09-19T01:11:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mikeross](https://avatars.discourse-cdn.com/v4/letter/m/3da27b/32.png) [@mikeross](https://support.prodi.gy/u/mikeross)\
**Post date:** [September 19, 2018, 1:11am UTC](https://support.prodi.gy/t/adding-column-from-csv-into-meta-with-custom-loader/822/1 "2018-09-19T01:11:04Z")

</div>

I am trying to add a column from a csv file into the meta field so that the “id” of each item can be viewed by the annotator. I have a custom loader, referencing your discussion in [Template for Prodigy corpus and API loaders](https://support.prodi.gy/t/template-for-prodigy-corpus-and-api-loaders/331)

I am trying the following:

```python
class CustomCsvLoader(object):

    def __init__ (self, filename):
        self.filename = filename

    def __iter__ (self):
        df = pd.read_csv(self.filename)
        for _, row in df.iterrows():
            text = row['text']
            id_text = row['id']
            yield {"text": text, "meta": {"id": id_text}}

@recipe('ner.custom-gold',
        dataset=recipe_args['dataset'],
        spacy_model=recipe_args['spacy_model'],
        source=recipe_args['source'],
        api=recipe_args['api'],
        label=recipe_args['label_set'],
        exclude=recipe_args['exclude'],
        unsegmented=recipe_args['unsegmented'])
def custom_gold(dataset, spacy_model, source=None, api=None,
              label=None, exclude=None, unsegmented=False):
    result = make_gold(dataset, spacy_model, source=None, api=None, loader=CustomCsvLoader(source),
        label=label, exclude=exclude, unsegmented=unsegmented)

    return result

```

It doesn’t seem that I am using the loader correctly. The following error is returned:

```python
  File "/venvs/dev3.6/lib/python3.6/site-packages/prodigy/recipes/ner.py", line 199, in make_gold
    dedup=True, input_key='text')
  File "cython_src/prodigy/components/loaders.pyx", line 51, in prodigy.components.loaders.get_stream
  File "cython_src/prodigy/components/loaders.pyx", line 104, in prodigy.components.loaders.get_loader
ValueError: No loader found for '<recipe.CustomCsvLoader object at 0x7f4938369710>'

```

Any help you can offer would be much appreciated!!

---

<div class="post-metadata">

**Author:** ![ines](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/ines/32/3_2.png) [@ines](https://support.prodi.gy/u/ines)\
**Post date:** [September 19, 2018, 9:48am UTC](https://support.prodi.gy/t/adding-column-from-csv-into-meta-with-custom-loader/822/2 "2018-09-19T09:48:56Z")

</div>

Your loader code looks good, but I think the problem here is this part:

```python
loader=CustomCsvLoader(source)

```

The `loader` argument is the _loader ID_, which Prodigy will resolve to one of the existing loaders (or a custom loader registered via entry points). For example, `'csv'` to use the default CSV loader.

In your case, you already have the loader and `CustomCsvLoader(source)` is the loaded source, i.e. the data stream. So you can pass this in as the `source` argument, or do `result['stream'] = CustomCsvLoader(source)`.

---

<div class="post-metadata">

**Author:** ![mikeross](https://avatars.discourse-cdn.com/v4/letter/m/3da27b/32.png) [@mikeross](https://support.prodi.gy/u/mikeross)\
**Post date:** [September 21, 2018, 12:37am UTC](https://support.prodi.gy/t/adding-column-from-csv-into-meta-with-custom-loader/822/3 "2018-09-21T00:37:32Z")

</div>

This worked like a charm. Thank you. Also, I just wanted to express my appreciation for how well the custom recipe hooks on prodigy are designed. Thank you for such a great product.

---

<div class="post-metadata">

**Author:** ![ines](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/ines/32/3_2.png) [@ines](https://support.prodi.gy/u/ines)\
**Post date:** [September 21, 2018, 7:56pm UTC](https://support.prodi.gy/t/adding-column-from-csv-into-meta-with-custom-loader/822/4 "2018-09-21T19:56:54Z")

</div>

@mikeross Thank you so much! It definitely took a few iterations to get the recipe API right and find the best balance of customisability and “just works out-of-the-box”. So it’s nice to hear that the design resonates 😃
