在javascript中从CSV文件读取数据时,如何解决奇怪的输出问题?

在javascript中从CSV文件读取数据时,如何解决奇怪的输出问题?,javascript,node.js,fs,papaparse,Javascript,Node.js,Fs,Papaparse,我正在读取一个csv文件,希望将其转换为一个数组字符串。我的文件如下所示: https://www.google.com/imghp?hl=en&tab=wi https://maps.google.com/maps?hl=en&tab=wl https://play.google.com/?hl=en&tab=w8 https://www.youtube.com/?gl=US&tab=w1 https://news.google.com/nwshp?hl=en&

我正在读取一个csv文件,希望将其转换为一个数组字符串。我的文件如下所示:

https://www.google.com/imghp?hl=en&tab=wi
https://maps.google.com/maps?hl=en&tab=wl
https://play.google.com/?hl=en&tab=w8
https://www.youtube.com/?gl=US&tab=w1
https://news.google.com/nwshp?hl=en&tab=wn
https://mail.google.com/mail/?tab=wm
https://drive.google.com/?tab=wo
https://www.google.com/intl/en/about/products?tab=wh
https://accounts.google.com/ServiceLogin?hl=en&passive=true&continue=https://www.google.com/
https://www.google.com/url?q=https://lifeinaday.youtube/%3Futm_source%3Dgoogle%26utm_medium%3Dhppcta%26utm_campaign%3D2020&source=hpp&id=19019062&ct=3&usg=AFQjCNEJMAD58Mjdnro8Mjm-RtJ3nfEIZA&sa=X&ved=0ahUKEwi98PWM4-HqAhVh1uAKHeYGCPwQ8IcBCAU
我正在运行这段代码来读取上面的csv文件,并将数据推送到csv_数据数组中

const fs = require('fs');
const Papa = require('papaparse');

const csvFilePath = 'anchors.csv'

const file = fs.createReadStream(csvFilePath);

var csvData=[];
Papa.parse(file, {
  header: true,
  step: function(result) {
    csvData.push(result.data)
  },
  complete: function(results, file) {
    console.log('Complete', csvData.length, 'records.'); 
    console.log(csvData)
  }
});
然而,我得到了这个奇怪的输出,用冒号和花括号分开

[  
  {
    'https://www.google.com/imghp?hl=en&tab=wi': 'https://maps.google.com/maps?hl=en&tab=wl'
  },
  {
    'https://www.google.com/imghp?hl=en&tab=wi': 'https://play.google.com/?hl=en&tab=w8'
  },
  {
    'https://www.google.com/imghp?hl=en&tab=wi': 'https://www.youtube.com/?gl=US&tab=w1'
  },
  {
    'https://www.google.com/imghp?hl=en&tab=wi': 'https://news.google.com/nwshp?hl=en&tab=wn'
  },
  {
    'https://www.google.com/imghp?hl=en&tab=wi': 'https://mail.google.com/mail/?tab=wm'
  },
  {
    'https://www.google.com/imghp?hl=en&tab=wi': 'https://drive.google.com/?tab=wo'
  },
  {
    'https://www.google.com/imghp?hl=en&tab=wi': 'https://www.google.com/intl/en/about/products?tab=wh'
  },
  {
    'https://www.google.com/imghp?hl=en&tab=wi': 'https://accounts.google.com/ServiceLogin?hl=en&passive=true&continue=https://www.google.com/'
  },
  {
    'https://www.google.com/imghp?hl=en&tab=wi': 'https://www.google.com/url?q=https://lifeinaday.youtube/%3Futm_source%3Dgoogle%26utm_medium%3Dhppcta%26utm_campaign%3D2020&source=hpp&id=19019062&ct=3&usg=AFQjCNEJMAD58Mjdnro8Mjm-RtJ3nfEIZA&sa=X&ved=0ahUKEwi98PWM4-HqAhVh1uAKHeYGCPwQ8IcBCAU'
  }
]

我做错了什么。我只需要用逗号分隔的整个字符串。如果有任何帮助,我们将不胜感激。谢谢。

这里没有问题,在CSV文件中,第一行是标题行(列的名称)。这里有一个名为'https://www.google.com/imghp?hl=en&tab=wi,所有后续行都是值行

尝试传递头:false。

CSV代表逗号分隔值文件扩展名。我在源文件中没有看到逗号!(?!)