简体   繁体   中英

How to read multiple csv files in for loop using javascript

I am reading a csv file in javascript using the code:

import csv
  
file = open(r'C:\Users\hu170f\Documents\TEST1\MAAP-S12_LH_UP_PASS-LN1-V1.csv')
csvreader = csv.reader(file)

Now I have multiple files in the same directory and I need to read all the files present in the directory sequentially in a for loop. How to proceed with this.

First of all, install and require all the dependencies. Example:

var fs = require('fs');
const path = require('path');
const mysqlConnection = require('./connection');
const fastcsv = require('fast-csv');

Loop through each CSV file argument and run the formatFile function on each

for (let i = 0; i < filePaths.length; i++) {
   formatFile(filePaths, i);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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