3
Answers

Upload CSV files.

Ankush Verma

Ankush Verma

2y
809
1

Hello everyone I have use papaparse library for read csv data it's working fine . But I have face a issue how to read multiple files.

Answers (3)
3
Amit Mohanty

Amit Mohanty

17 52.2k 6.1m 2y

Check the below code this may help you.

$(document).ready(function() {
  var files = ['file1.csv', 'file2.csv', 'file3.csv'];
  var results = [];

  function readFile(index) {
    if (index >= files.length) {
      // All files have been processed
      console.log(results);
      return;
    }

    $.ajax({
      type: 'GET',
      url: files[index],
      dataType: 'text',
      success: function(data) {
        var csvData = Papa.parse(data).data;
        results.push(csvData);
        readFile(index + 1);
      }
    });
  }

  readFile(0);
});
Accepted
3
Rajesh Gami

Rajesh Gami

78 24.4k 1.3m 2y
var files = Directory.EnumerateFiles("path", "*.csv");
foreach (string file in files)
{
    using (FileStream fs = new FileStream(file, FileMode.Open, FileAccess.Read))
    {
        // Use the file stream to read data.
    }
}
2
Aravind  Govindaraj

Aravind Govindaraj

316 5.9k 331.5k 2y

could you please refer this link 

https://medium.com/@kishanvikani/parse-multiple-files-using-papa-parse-and-perform-some-synchronous-task-2db18e531ede