简体   繁体   English

如何使用VS Code在JavaScript中的数组中存储csv文件的内容

[英]How to store content of csv file in an Array in JavaScript using VS Code

I am using VS Code and running Javascript. 我正在使用VS Code并运行Javascript。 Beside VS Code I have installed Node in my computer. 除了VS Code,我已经在计算机中安装了Node I am using windows. 我正在使用Windows。 I have csv file in the same folder as my .js file. 我的.js文件位于同一个文件夹中的csv文件。

How do I save the content of the csv file into an array? 如何将csv文件的内容保存到数组中?

Let's say my csv file have this content and I want to store it as an array variable A : 假设我的csv文件包含此内容,我想将其存储为数组变量A

101,MS,100000 102,LS,80000 103,TS,60000 104,VB,200000 105,PB,180000 106,AB,160000

Since you have node installed, you could use a npm package https://www.npmjs.com/package/csv-string to do so. 由于已安装节点,因此可以使用npm软件包https://www.npmjs.com/package/csv-string进行安装。

They have listed out all the ways that can be used to generate an array. 他们列出了可用于生成数组的所有方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM