# Save a FreeFEM Matrix in Python format

**URL:** https://community.freefem.org/t/save-a-freefem-matrix-in-python-format/1954
**Category:** General Discussion
**Created:** [August 23, 2022, 7:09am UTC](https://community.freefem.org/t/save-a-freefem-matrix-in-python-format/1954 "2022-08-23T07:09:59Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Loic](https://avatars.discourse-cdn.com/v4/letter/l/e9c0ed/32.png) [@Loic](https://community.freefem.org/u/Loic)
#### Post date: [August 23, 2022, 7:09am UTC](https://community.freefem.org/t/save-a-freefem-matrix-in-python-format/1954/1 "2022-08-23T07:09:59Z")

</div>

Hello all,

I would like to know how to save a FreeFEM matrix, to open it with Python ?

Now, I save my matrix like this:

```auto
string MatrixAglobal="Aglobal.txt";
ofstream saveA(MatrixAglobal);
saveA << Aglobal << endl;

```

And when I am trying to open it with Python:

```auto
import numpy as np
data=np.load('Aglobal.txt')

```

I get this error:

> ValueError: Cannot load file containing pickled data when allow\_pickle=False

Thank you,

Best regards,

Loïc,

---

<div class="post-metadata">

### Author: ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)
#### Post date: [August 23, 2022, 7:16am UTC](https://community.freefem.org/t/save-a-freefem-matrix-in-python-format/1954/2 "2022-08-23T07:16:50Z")

</div>

Use a PETSc `Mat` and then use `petsc4py` in your Python script.
