# Exporting table from relatedness

**URL:** <https://discuss.hail.is/t/exporting-table-from-relatedness/2084>\
**Category:** Hail Query & hailctl\
**Created:** [June 16, 2021, 10:31am UTC](https://discuss.hail.is/t/exporting-table-from-relatedness/2084 "2021-06-16T10:31:40Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![bonsai](https://avatars.discourse-cdn.com/v4/letter/b/34f0e0/32.png) [@bonsai](https://discuss.hail.is/u/bonsai)\
**Post date:** [June 16, 2021, 10:31am UTC](https://discuss.hail.is/t/exporting-table-from-relatedness/2084/1 "2021-06-16T10:31:40Z")

</div>

Hi there,

I would like to export this relatedness table/mt as a csv or tsv file and have done so as per this command:

mt.write(‘kinship\_table.tsv’)

However this exports the table out as a folder instead of a single csv file that I can open up in excel. table.export(‘file.tsv’) does not work…is there something I’m missing here?

 ![Screenshot 2021-06-16 at 10.27.37](https://canada1.discourse-cdn.com/flex036/uploads/hail/original/1X/a518c96a0cac685cee6ec49d43e209b59b95084d.png)

Many thanks,

---

<div class="post-metadata">

**Author:** ![tpoterba](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.hail.is/tpoterba/32/61_2.png) [@tpoterba](https://discuss.hail.is/u/tpoterba)\
**Post date:** [June 16, 2021, 10:49am UTC](https://discuss.hail.is/t/exporting-table-from-relatedness/2084/2 "2021-06-16T10:49:48Z")

</div>

Does `mt.entries().export(...)` do what you want here?

---

<div class="post-metadata">

**Author:** ![bonsai](https://avatars.discourse-cdn.com/v4/letter/b/34f0e0/32.png) [@bonsai](https://discuss.hail.is/u/bonsai)\
**Post date:** [June 16, 2021, 1:37pm UTC](https://discuss.hail.is/t/exporting-table-from-relatedness/2084/3 "2021-06-16T13:37:48Z")

</div>

Hi Tim,

Thank you, that’s great! It’s worked so far as exporting a table in 2 columns. This is very large, however, creating approx 3 mill rows. How would I preserve the way the matrix is set up as per the image above, as in, how would I add the ‘key\_cols\_by()’ to the command you’ve just sent me?

Many thanks

---

<div class="post-metadata">

**Author:** ![tpoterba](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.hail.is/tpoterba/32/61_2.png) [@tpoterba](https://discuss.hail.is/u/tpoterba)\
**Post date:** [June 16, 2021, 9:01pm UTC](https://discuss.hail.is/t/exporting-table-from-relatedness/2084/4 "2021-06-16T21:01:58Z")

</div>

Ah! I see. There’s no `MatrixTable.export`, but I think that `mt.phi.export(...)` will generate a tab-separated matrix.

---

<div class="post-metadata">

**Author:** ![bonsai](https://avatars.discourse-cdn.com/v4/letter/b/34f0e0/32.png) [@bonsai](https://discuss.hail.is/u/bonsai)\
**Post date:** [June 17, 2021, 10:13am UTC](https://discuss.hail.is/t/exporting-table-from-relatedness/2084/5 "2021-06-17T10:13:57Z")

</div>

That’s the one! Thanks Tim.
