fast-csv icon indicating copy to clipboard operation
fast-csv copied to clipboard

[BUG] Varying length of row and headers: false

Open Crusader4Christ opened this issue 3 years ago • 1 comments

Describe the bug Can't make csv file with varying length of row and headers: false.

var array = [
  [1],
  [1,2,3],
]

How can I save such structure to csv? Also I need some way to save rows of varying length WITHOUT empty delimiters, to produce

1,2,3
1

from this array

var array = [
  [1,2,3],
  [1],
]

Parsing or Formatting?

  • [x] Formatting
  • [ ] Parsing

Crusader4Christ avatar May 14 '21 14:05 Crusader4Christ

@Crusader4Christ : Hi Christ,

I have checked above issue and its working fine with latest version : 4.3.6. Few Test Cases i have checked:

Case 1:

var array = [
    [1],
    [3, 4, 5],
    [1,2,3],
    [1,2, 3, 4]
  ]
  writeToPath(path.resolve(__dirname, 'tmp.csv'), array)
    .on('error', err => console.error(err))
    .on('finish', () => console.log('Done writing.'));

tmp.csv data :

1
3,4,5
1,2,3
1,2,3,4

Case 2

var array = [
    [1, 2, 3, 4, 5, 6, 7],
    [3, 4, 5],
    [1,2,3],
    [1,2, 3, 4]
  ]
  writeToPath(path.resolve(__dirname, 'tmp.csv'), array)
    .on('error', err => console.error(err))
    .on('finish', () => console.log('Done writing.'));

tmp.csv data:

1,2,3,4,5,6,7
3,4,5
1,2,3
1,2,3,4

Please let me know if you are still facing this issue or any specific case that is breaking.

Thanks

Rishabh-C2FO avatar May 25 '21 16:05 Rishabh-C2FO