# Exporting not\_flagged annotation

**URL:** <https://support.prodi.gy/t/exporting-not-flagged-annotation/1340>\
**Category:** Uncategorized\
**Tags:** usage, database, solved\
**Created:** [March 25, 2019, 1:27pm UTC](https://support.prodi.gy/t/exporting-not-flagged-annotation/1340 "2019-03-25T13:27:46Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ivo](https://avatars.discourse-cdn.com/v4/letter/i/ee7513/32.png) [@ivo](https://support.prodi.gy/u/ivo)\
**Post date:** [March 25, 2019, 1:27pm UTC](https://support.prodi.gy/t/exporting-not-flagged-annotation/1340/1 "2019-03-25T13:27:47Z")

</div>

I am having all examples in 1dataset. From there I am able to export only the flagged via -F key (I can even re-add them as new dataset)

However, how I can export only the unflagged examples. Is there recipe that could be used for this?

edit:  
the use case is : for training I need only the unflagged examples to make ner.gold-to-spacy

---

<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:** [March 25, 2019, 1:41pm UTC](https://support.prodi.gy/t/exporting-not-flagged-annotation/1340/2 "2019-03-25T13:41:03Z")

</div>

When you flag an example, Prodigy will add `"flagged": True` to the annotation example. So you could write a script that gets the examples in a dataset and filters out examples that have `"flagged"` set to `True`. For example:

```python
from prodigy.components.db import connect

db = connect()
examples = db.get_dataset("your_dataset")
filtered_examples = [eg for eg in examples if not eg.get("flagged")]

```

You could then save out the filtered examples to a JSONL file, or use `db.add_dataset` and `db.add_examples` to create a new dataset and add the filtered examples to it. You can find more details on the available database methods in the “Database” section of your `PRODIGY_README.html`.

---

<div class="post-metadata">

**Author:** ![ivo](https://avatars.discourse-cdn.com/v4/letter/i/ee7513/32.png) [@ivo](https://support.prodi.gy/u/ivo)\
**Post date:** [March 25, 2019, 2:00pm UTC](https://support.prodi.gy/t/exporting-not-flagged-annotation/1340/3 "2019-03-25T14:00:47Z")

</div>

Thanks for the fast reply, I tried the script but I am receiving error on

`examples = db.get_examples("dataset_name")`

it dumps some lines and ends with

ValueError: invalid literal for int() with base 10: ‘d’

---

<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:** [March 25, 2019, 2:02pm UTC](https://support.prodi.gy/t/exporting-not-flagged-annotation/1340/4 "2019-03-25T14:02:04Z")

</div>

Sorry, that was a typo in my example – I meant the `get_dataset` method that takes the name of a dataset and returns the examples. Just edited the code in my previous post.

---

<div class="post-metadata">

**Author:** ![ivo](https://avatars.discourse-cdn.com/v4/letter/i/ee7513/32.png) [@ivo](https://support.prodi.gy/u/ivo)\
**Post date:** [March 25, 2019, 2:08pm UTC](https://support.prodi.gy/t/exporting-not-flagged-annotation/1340/5 "2019-03-25T14:08:38Z")

</div>

now it works, thanks!

however, it is weird because in the Readme there is actually a proper method METHOD Database.get\_examples. Although it might do another thing

---

<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:** [March 25, 2019, 2:15pm UTC](https://support.prodi.gy/t/exporting-not-flagged-annotation/1340/6 "2019-03-25T14:15:50Z")

</div>

Yes, `Database.get_examples` is the method that gets _individual examples_ from a list of example IDs. `Database.get_dataset` gets all examples in a dataset, given the dataset ID.
