# Output sparse matrix to csv

**URL:** <https://discourse.julialang.org/t/output-sparse-matrix-to-csv/67513>\
**Category:** General Usage\
**Tags:** question, csv, sparse\
**Created:** [September 1, 2021, 3:31pm UTC](https://discourse.julialang.org/t/output-sparse-matrix-to-csv/67513 "2021-09-01T15:31:42Z")\
**Posts on this page:** 6\
**Page:** 2

<div class="post-metadata">

**Author:** ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)\
**Post date:** [September 1, 2021, 9:26pm UTC](https://discourse.julialang.org/t/output-sparse-matrix-to-csv/67513/23 "2021-09-01T21:26:50Z")

</div>

Yeah, read my message above where I mention this. We are still missing a step, a way to have a sparse matrix where the 0-value is `missing`. I know it exists, hopefully someone else can help.

---

<div class="post-metadata">

**Author:** ![Nenndul](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nenndul/32/22149_2.png) [@Nenndul](https://discourse.julialang.org/u/Nenndul)\
**Post date:** [September 1, 2021, 9:28pm UTC](https://discourse.julialang.org/t/output-sparse-matrix-to-csv/67513/24 "2021-09-01T21:28:09Z")

</div>

Thanks, it’s great to have a second method to do this though, it’ll probably come in handy at some point.

It’s mostly just an optimization thing that I’d like to sort out early because I’m doing wavelets and will never need those empty cells, basically. So sparse matrices are ideal for what I need.

---

<div class="post-metadata">

**Author:** ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)\
**Post date:** [September 1, 2021, 9:29pm UTC](https://discourse.julialang.org/t/output-sparse-matrix-to-csv/67513/25 "2021-09-01T21:29:48Z")

</div>

Maybe it’s [this](https://github.com/francescoalemanno/DefaultArrays.jl)?

See some old discussion [here](https://discourse.julialang.org/t/sparse-with-default-value-inf/35110/27).

Just as an aside, if your data is small enough to open up in excel, you might not need a sparse matrix at all.

---

<div class="post-metadata">

**Author:** ![Nenndul](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nenndul/32/22149_2.png) [@Nenndul](https://discourse.julialang.org/u/Nenndul)\
**Post date:** [September 1, 2021, 9:41pm UTC](https://discourse.julialang.org/t/output-sparse-matrix-to-csv/67513/26 "2021-09-01T21:41:46Z")

</div>

Oh, this looks like it might be useful in the end:

> **[GitHub - JuliaArrays/ArraysOfArrays.jl: Efficient storage and handling of...](https://github.com/JuliaArrays/ArraysOfArrays.jl)**
>
> Efficient storage and handling of nested arrays in Julia - GitHub - JuliaArrays/ArraysOfArrays.jl: Efficient storage and handling of nested arrays in Julia

> Just as an aside, if your data is small enough to open up in excel, you might not need a sparse matrix at all.

You’re right. The way I’m hoping for this to work might only need to output something readable at the very last step, so converting to a dense array at that point probably doesn’t matter one way or another.

The data size is flexible though, eventually I would like to be able to use much larger sets than Excel could handle (wav files, basically)

Still a long way for me to go to get there though, 🤣, but I have the basic groundwork covered and can use Excel to evaluate outputs as I go in the meantime still to see if everything works as it should.

---

<div class="post-metadata">

**Author:** ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)\
**Post date:** [September 1, 2021, 9:44pm UTC](https://discourse.julialang.org/t/output-sparse-matrix-to-csv/67513/27 "2021-09-01T21:44:05Z")

</div>

Wait why is this relevant to your current problem?

---

<div class="post-metadata">

**Author:** ![Nenndul](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nenndul/32/22149_2.png) [@Nenndul](https://discourse.julialang.org/u/Nenndul)\
**Post date:** [September 1, 2021, 9:46pm UTC](https://discourse.julialang.org/t/output-sparse-matrix-to-csv/67513/28 "2021-09-01T21:46:33Z")

</div>

You mean array of arrays?

Not for the current problem, no. But I will want to do operations on the arrays that may go a couple of layers deep in the end.

A bit of a variation on this sort of thing: [https://file.scirp.org/Html/2-1630011/dff8c838-6c24-4e6a-abda-5459bed729bf.jpg](https://file.scirp.org/Html/2-1630011/dff8c838-6c24-4e6a-abda-5459bed729bf.jpg)

from here: [SWAT and Wavelet Analysis for Understanding the Climate Change Impact on Hydrologic Response](https://file.scirp.org/Html/2-1630011_18560.htm)

I have the whole operation running on Excel, but as you can imagine it takes days to run things when they get a couple of layers deep. I think understand what I want to do well enough now that its time to port to something a bit more practical. I tried Python before but it didn’t improve speed enough to warrant losing the visual directness while I was playing around with things.

Enter Julia.

[Previous page](https://discourse.julialang.org/t/output-sparse-matrix-to-csv/67513.md?page=1)
