Can't read an appended csv file

Describe the problem/error/question

I’ve made a workflow that will append new data to a csv file but the problem is when I run the workflow twice it’ll no longer can read the appended csv file cause it gives error. It works fine when you run it the first time but when you run it again it causes error. Does anyone know how to fix this?

here are the csv files for testing https://www.dropbox.com/scl/fi/ge4g99aidf29hh6n1kxnd/comic.csv?rlkey=7p69sbavlzz9m48bubzpetpcw&st=t9ku8h4p&dl=0
https://www.dropbox.com/scl/fi/elr61u5yvz9uqnevo9jaq/comic-new.csv?rlkey=3pf62fw2hk385gcas5t2p5eiz&st=comksg1z&dl=0

What is the error message (if any)?

Invalid Record Length: columns length is 5, got 13 on line 804

Please share your workflow

Share the output returned by the last node

Information on your n8n setup

  • n8n version: 2.2.3
  • Database (default: SQLite): default
  • n8n EXECUTIONS_PROCESS setting (default: own, main): default
  • Running n8n via (Docker, npm, n8n cloud, desktop app): npm
  • Operating system: Ubuntu 24.04 LTS

Hi @Ruriko

Replace your SSH command with this version and run the workflow 2x and update me

echo "{{ $json.comic }};{{ $json.id }};{{ $json.title }};{{ $json.Date }};{{ $json.isNewSerialization }}" >> /var/www/comic.adoreanime.com/htdocs/comic.csv

Hi @Ruriko,

n8n’s Extract from File node seems to have a bug with Japanese CJK characters, it misparses them despite perfect CSV structure.

If you replace the read file s and extract nodes with this code, it seems to work

Try the below work around

2 Likes

It doesn’t work it still gives the same error but in your version I notice you use {{ $json.comic }} but that gives me [undefined] in the Result page where as If I use {{ $json[‘comic’] }} it’ll give the output

Might be because I modified the csv. There was an invisible BOM character ( U+FEFF) in your comic field name hence your requirement to use {{ $json[‘comic’] }}.

When you say it doesnt work, are you getting the same error?

You can try and manually editing both csv files by recreating the header column for “comic” to remove the BOM issue.

Further to my work around you need to make sure you enable fs with

NODE_FUNCTION_ALLOW_BUILTIN=fs

To further make the code node re-usable without having to duplicate the code everytime you want to read the file, move the code node to a separate workflow and call it as a sub workflow passing in the file path you want to read.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.