ryu1kn / csv-writer

Convert objects/arrays into a CSV string or write them into a CSV file
https://www.npmjs.com/package/csv-writer
MIT License
246 stars 39 forks source link

Writing CSVs to external media on linux #50

Closed nibman closed 4 years ago

nibman commented 4 years ago

Hi, I've stumbled upon what seems to be an issue when trying to save on a mounted usb drive (or key) on linux. The library works well and I've used it many times on a few projects, but the project I'm currently working on requires data to be saved on an external storage.

The media is properly mounted and accessible, and I'm even writing and reading JSON files on it using node's FS module.

As an exemple, the accessible mounted path for my storage is : "/mnt/usbKey" . Whenever I try to write at this path I get the following error:

{ [Error: EINVAL: invalid argument, open '/mnt/usbKey/logs-2020-06-25T23:46:26+00:00.csv'] errno: -22, code: 'EINVAL', syscall: 'open', path: '/mnt/usbKey/logs-2020-06-25T23:46:26+00:00.csv' }

At first I thought I was facing a path issue so I've tried many things like passing the absolute path, resolving it with node's path module, etc... but no cigars. I always end up stuck here.

My code works perfectly if I try to save it on the box's disk, but as soon as I try the usb storage, I get this error. I'm still doubting this is a path issue, but I usually get around those pretty quickly. Unfortunately, this one.... I can't seem to get it right.

And as I mentioned earlier, I can save other files on the storage, using the same path, with no issues.

Any idea ? Help would be greatly appreciated.

Thanks a mil for the lib, it's awesome.... just not today. :)

nibman commented 4 years ago

Well, I am going to close the issue myself, because after hours of looking around I've realized that filenames on mounted drives on linux are using a different set of rules than the host's disk.

The issue was with Linux and odd or special characters in the actual file name. Especially the ":" ....

Silly me. Thanks again.

ryu1kn commented 4 years ago

Glad that you found the cause, and thanks for updating me with what was happening.

Also thanks for your encouraging comment. I'm happy that the library is helping your projects 😉