简体   繁体   English

Javascript如何更改JavaScript数组格式?

[英]Javascript how do I change javascript array format?

I am creating a file upload operation where I'll retrieve content of file and perform some function with them. 我正在创建文件上传操作,在该操作中,我将检索文件内容并对其执行某些功能。

I ask users to enter data in the format below in an excel sheet and save the excel file as a CSV file. 我要求用户在Excel工作表中以以下格式输入数据,并将Excel文件另存为CSV文件。

在此处输入图片说明 Then I use this function to read an display the file content. 然后,我使用此功能读取显示的文件内容。

    var fileInput = document.getElementById("csv");

      readFile = function () {

              console.log("file uploaded");
              var reader = new FileReader();
              reader.onload = function () {
            reader.readAsBinaryString(fileInput.files[0]);
            };
            }
            if (fileInput){
                fileInput.addEventListener('change', readFile);
            }

the function output this image. 函数输出此图像。 在此处输入图片说明

what I have not been able to figure out is how do I convert and arrange from the file output format to the desired output format. 我一直无法弄清楚的是如何将文件输出格式转换和排列为所需的输出格式。

var numbers = [75799757,9744710,79989647,99029704,]; 变数= [75799757,9744710,79989647,99029704,];

在此处输入图片说明

 var numbers = [75799757,9744710,79989647,99029704]; var str=""; numbers.forEach(function(number){ str += number + ", "; }); var newStr = str.substring(0, str.length-2); document.write(newStr); 

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

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