# Convert Binary file To JSON or CSV

**URL:** <https://community.n8n.io/t/convert-binary-file-to-json-or-csv/24593>\
**Category:** Questions\
**Tags:** transform-binary\
**Created:** [March 28, 2023, 2:53pm UTC](https://community.n8n.io/t/convert-binary-file-to-json-or-csv/24593 "2023-03-28T14:53:25Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gabriele\_Bracciali](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/gabriele_bracciali/32/31293_2.png) [@Gabriele\_Bracciali](https://community.n8n.io/u/Gabriele_Bracciali)\
**Post date:** [March 28, 2023, 2:53pm UTC](https://community.n8n.io/t/convert-binary-file-to-json-or-csv/24593/1 "2023-03-28T14:53:25Z")

</div>

## Describe the issue/error/question

Hello everyone, I have to transform a file in Binary (more than 400mb) downloaded from sFTP server and then, use that data in a CSV or JSON format.

Do you know the best way to handle a file like that and convert it in CSV or JSON?

## What is the error message (if any)?

## Please share the workflow

I’ve used the node “Move binary data” but it return me a string error formatting, so it fail

I’ve tried to use the “CSV” node, read and write new file, but it return empty item

## Share the output returned by the last node

## Information on your n8n setup

- \*\*n8n version:\*\*0.217.2
- **Database you’re using (default: SQLite):** npm version
- **Running n8n with the execution process [own(default), main]:**
- **Running n8n via [Docker, npm, n8n.cloud, desktop app]:**

---

<div class="post-metadata">

**Author:** ![MutedJam](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/mutedjam/32/70851_2.png) [@MutedJam](https://community.n8n.io/u/MutedJam)\
**Post date:** [March 28, 2023, 3:01pm UTC](https://community.n8n.io/t/convert-binary-file-to-json-or-csv/24593/2 "2023-03-28T15:01:21Z")

</div>

Hi @Gabriele_Bracciali, I am sorry to hear you’re having trouble.

Tbh I think that file size could be a bit too much to parse at once for most n8n instances. But perhaps we can come up with a workaround. Is the file you are downloading a CSV file or something else that you would need to convert first? And do you have an example file by any chance?

---

<div class="post-metadata">

**Author:** ![Gabriele\_Bracciali](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/gabriele_bracciali/32/31293_2.png) [@Gabriele\_Bracciali](https://community.n8n.io/u/Gabriele_Bracciali)\
**Post date:** [March 28, 2023, 3:27pm UTC](https://community.n8n.io/t/convert-binary-file-to-json-or-csv/24593/3 "2023-03-28T15:27:09Z")

</div>

it’s a CSV file the input.

---

<div class="post-metadata">

**Author:** ![Gabriele\_Bracciali](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/gabriele_bracciali/32/31293_2.png) [@Gabriele\_Bracciali](https://community.n8n.io/u/Gabriele_Bracciali)\
**Post date:** [March 29, 2023, 7:19am UTC](https://community.n8n.io/t/convert-binary-file-to-json-or-csv/24593/4 "2023-03-29T07:19:49Z")

</div>

@MutedJam

| email | id\_newsletter | id\_client | genre\_BI | rfm\_actuel | rfm\_precedent | rfm\_anciennete | rfm\_date\_rafraichissement | marge\_ht\_apres\_log\_total | sport\_client | marques\_clients\_N1 | marques\_clients\_N5 | date\_last\_cmd\_mag | last\_cmd\_mag | closest\_shop\_name | distance\_to\_closest\_shop | update\_time\_bi |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| \*test.test@sd.fr | 25123859 | 2224656 | monsieur | 8. To test | 5. New | 38 | 28/03/2023 | | Route | 136746,1,2238425,2 | 136746,1,2238425,2 | | | BBA | 25 | 28/03/2023 |

This is the flow:  
download action on FTP node, then try to convert it

 ![Screenshot 2023-03-29 at 11.12.25](https://europe1.discourse-cdn.com/n8n/original/3X/e/e/ee0bbf4cb3e0304d0401c2292240f47f15550a31.png)

---

<div class="post-metadata">

**Author:** ![MutedJam](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/mutedjam/32/70851_2.png) [@MutedJam](https://community.n8n.io/u/MutedJam)\
**Post date:** [March 29, 2023, 9:54am UTC](https://community.n8n.io/t/convert-binary-file-to-json-or-csv/24593/5 "2023-03-29T09:54:18Z")

</div>

So this is a bit tricky, but I think a possible approach would be to store that huge file on the file system, then read it in chunks. This will only work if you’re not using n8n cloud though and you would need to adjust the paths used in this workflow to your own folder structure. But the basic idea could be to have a parent workflow like this to download a large file, write it to the file system and then prepare batches:

Then call a sub-workflow reading only a limited number of lines at once from that file, do something with it and then return only a very small result set to the parent rather than the full data:

Memory usage was quite low when testing this with a dummy file:

 ![image](https://europe1.discourse-cdn.com/n8n/original/3X/b/5/b5d205b834e5085ff60bde94aa2dd05ba2c3c2b6.png)

Now this is assuming your CSV file is properly formatted and the only problem is indeed its size. If not It’d be great if you could share an actual example of one of these files (you can of course redact anything confidential, the only thing that matter is that any issues you might have can be reproduced with it).

Hope this helps!

---

<div class="post-metadata">

**Author:** ![Gabriele\_Bracciali](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/gabriele_bracciali/32/31293_2.png) [@Gabriele\_Bracciali](https://community.n8n.io/u/Gabriele_Bracciali)\
**Post date:** [March 29, 2023, 11:50am UTC](https://community.n8n.io/t/convert-binary-file-to-json-or-csv/24593/6 "2023-03-29T11:50:01Z")

</div>

I am receiving Permission denied error in the “Count lines in file” node

---

<div class="post-metadata">

**Author:** ![MutedJam](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/mutedjam/32/70851_2.png) [@MutedJam](https://community.n8n.io/u/MutedJam)\
**Post date:** [March 29, 2023, 11:57am UTC](https://community.n8n.io/t/convert-binary-file-to-json-or-csv/24593/7 "2023-03-29T11:57:25Z")

</div>

So this could be a problem on your local filesystem. You might need to swap the file paths used in the workflow to a path that exists on your side and in which you have full permissions. Also, to run the sub-workflow individually you might need to use data pinning first to supply some dummy data.

To do so, first copy the data from the parent:

 ![image](https://europe1.discourse-cdn.com/n8n/original/3X/1/6/16f3aac62bbaced8d638adf93923f6216202e6b9.png)

Then, in the sub-workflow click this button to edit the test data:

 ![image](https://europe1.discourse-cdn.com/n8n/original/3X/b/7/b798e80755c3fd58b022eb6f07d2d739087da017.png)

Finally, paste the test data and hit Save:

 ![image](https://europe1.discourse-cdn.com/n8n/original/3X/a/c/aca8a1eb98b45884583ce3b12dc2c5861f42f629.png)

Afterwards you should be able to run your sub-workflow on its own for testing purposes:

 ![image](https://europe1.discourse-cdn.com/n8n/original/3X/7/4/74d226198482e33b7131459e46175948a5c09c80.png)

---

<div class="post-metadata">

**Author:** ![Gabriele\_Bracciali](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/gabriele_bracciali/32/31293_2.png) [@Gabriele\_Bracciali](https://community.n8n.io/u/Gabriele_Bracciali)\
**Post date:** [March 29, 2023, 11:59am UTC](https://community.n8n.io/t/convert-binary-file-to-json-or-csv/24593/8 "2023-03-29T11:59:32Z")

</div>

I’ve tried:  
/Users/gabrielebracciali/n8ntemp{{ $binary.data.fileName }}  
Here maybe I dont’have full permission, but I have changed into desktop and same permission error.

I am not arrived at the second workflow yet.

---

<div class="post-metadata">

**Author:** ![MutedJam](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/mutedjam/32/70851_2.png) [@MutedJam](https://community.n8n.io/u/MutedJam)\
**Post date:** [March 29, 2023, 1:23pm UTC](https://community.n8n.io/t/convert-binary-file-to-json-or-csv/24593/9 "2023-03-29T13:23:11Z")

</div>

Hi @Gabriele_Bracciali, is your n8n instance perhaps running as a user other than gabrielebracciali, so it doesn’t have permissions to write into said user directory? What if you create a designated folder on your hard drive and simply allow everyone to write in there (just for testing purposes)?

---

<div class="post-metadata">

**Author:** ![Gabriele\_Bracciali](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/gabriele_bracciali/32/31293_2.png) [@Gabriele\_Bracciali](https://community.n8n.io/u/Gabriele_Bracciali)\
**Post date:** [March 29, 2023, 1:35pm UTC](https://community.n8n.io/t/convert-binary-file-to-json-or-csv/24593/10 "2023-03-29T13:35:04Z")

</div>

Idk, I’ve setted the Sharing & Permission option like everyone Read & Write, but same error.  
mac user

---

<div class="post-metadata">

**Author:** ![MutedJam](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/mutedjam/32/70851_2.png) [@MutedJam](https://community.n8n.io/u/MutedJam)\
**Post date:** [March 29, 2023, 1:38pm UTC](https://community.n8n.io/t/convert-binary-file-to-json-or-csv/24593/11 "2023-03-29T13:38:02Z")

</div>

Are you by any chance not running n8n through npm (as suggested above) but using Docker (which would be the common way of doing so)?

---

<div class="post-metadata">

**Author:** ![Gabriele\_Bracciali](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/gabriele_bracciali/32/31293_2.png) [@Gabriele\_Bracciali](https://community.n8n.io/u/Gabriele_Bracciali)\
**Post date:** [March 29, 2023, 1:39pm UTC](https://community.n8n.io/t/convert-binary-file-to-json-or-csv/24593/12 "2023-03-29T13:39:00Z")

</div>

I am running n8n through npm

---

<div class="post-metadata">

**Author:** ![MutedJam](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/mutedjam/32/70851_2.png) [@MutedJam](https://community.n8n.io/u/MutedJam)\
**Post date:** [March 29, 2023, 1:41pm UTC](https://community.n8n.io/t/convert-binary-file-to-json-or-csv/24593/13 "2023-03-29T13:41:00Z")

</div>

Hm, I am afraid I don’t know why writing to the file system would fail in your case ☹

I don’t have a Mac though, so perhaps this OS adds some additional isolation layers somewhere along the way. Maybe fellow Mac user @Jon knows more about this?

---

<div class="post-metadata">

**Author:** ![Gabriele\_Bracciali](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/gabriele_bracciali/32/31293_2.png) [@Gabriele\_Bracciali](https://community.n8n.io/u/Gabriele_Bracciali)\
**Post date:** [March 29, 2023, 1:45pm UTC](https://community.n8n.io/t/convert-binary-file-to-json-or-csv/24593/14 "2023-03-29T13:45:17Z")

</div>

Okay okay, thank you for your help, and sorry If we are going a bit off-topic with this other issue.

---

<div class="post-metadata">

**Author:** ![MutedJam](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/mutedjam/32/70851_2.png) [@MutedJam](https://community.n8n.io/u/MutedJam)\
**Post date:** [March 29, 2023, 1:46pm UTC](https://community.n8n.io/t/convert-binary-file-to-json-or-csv/24593/15 "2023-03-29T13:46:38Z")

</div>

That’s alright, very large files can be very tricky in n8n. It’s why I thought handling these outside of n8n itself would make things easier, but I was clearly wrong 🙈

---

<div class="post-metadata">

**Author:** ![Jon](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/jon/32/40174_2.png) [@Jon](https://community.n8n.io/u/Jon)\
**Post date:** [March 29, 2023, 1:52pm UTC](https://community.n8n.io/t/convert-binary-file-to-json-or-csv/24593/16 "2023-03-29T13:52:42Z")

</div>

Hey @Gabriele_Bracciali,

Could you share the full error so I can take a look?

---

<div class="post-metadata">

**Author:** ![Gabriele\_Bracciali](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/gabriele_bracciali/32/31293_2.png) [@Gabriele\_Bracciali](https://community.n8n.io/u/Gabriele_Bracciali)\
**Post date:** [March 29, 2023, 1:53pm UTC](https://community.n8n.io/t/convert-binary-file-to-json-or-csv/24593/17 "2023-03-29T13:53:20Z")

</div>

ERROR: Command failed: /Users/gabrielebracciali/n8ntemp/upload/flux\_user\_bi.csv /bin/sh: /Users/gabrielebracciali/n8ntemp/upload/flux\_user\_bi.csv: Permission denied

```auto
NodeOperationError: Command failed: /Users/gabrielebracciali/n8ntemp/upload/flux_user_bi.csv
/bin/sh: /Users/gabrielebracciali/n8ntemp/upload/flux_user_bi.csv: Permission denied

    at Object.execute (/opt/homebrew/lib/node_modules/n8n/node_modules/n8n-nodes-base/nodes/ExecuteCommand/ExecuteCommand.node.ts:96:12)
    at Workflow.runNode (/opt/homebrew/lib/node_modules/n8n/node_modules/n8n-workflow/src/Workflow.ts:1270:19)
    at /opt/homebrew/lib/node_modules/n8n/node_modules/n8n-core/src/WorkflowExecute.ts:949:29

```

---

<div class="post-metadata">

**Author:** ![Jon](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/jon/32/40174_2.png) [@Jon](https://community.n8n.io/u/Jon)\
**Post date:** [March 29, 2023, 2:33pm UTC](https://community.n8n.io/t/convert-binary-file-to-json-or-csv/24593/18 "2023-03-29T14:33:41Z")

</div>

Can you share the input of the execute command node? My initial thought is maybe you are missing the command and just have the file path in there.

---

<div class="post-metadata">

**Author:** ![Gabriele\_Bracciali](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/gabriele_bracciali/32/31293_2.png) [@Gabriele\_Bracciali](https://community.n8n.io/u/Gabriele_Bracciali)\
**Post date:** [March 29, 2023, 3:08pm UTC](https://community.n8n.io/t/convert-binary-file-to-json-or-csv/24593/19 "2023-03-29T15:08:39Z")

</div>



---

<div class="post-metadata">

**Author:** ![Gabriele\_Bracciali](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/gabriele_bracciali/32/31293_2.png) [@Gabriele\_Bracciali](https://community.n8n.io/u/Gabriele_Bracciali)\
**Post date:** [March 29, 2023, 3:15pm UTC](https://community.n8n.io/t/convert-binary-file-to-json-or-csv/24593/20 "2023-03-29T15:15:39Z")

</div>

I’ve searched online about this error: Permission denied

also used the terminal for allow permission, but doesn’t work.  
Same error

[Next page](https://community.n8n.io/t/convert-binary-file-to-json-or-csv/24593.md?page=2)
