There's a demand today. csv file
I was going to use the xlsx bag I used.
But I couldn't find a way to read a CSV document. I'm not happy to test the code.
I used to see a nodejs document when I saw a line read the file, is this CSV file used exactly?
and toss it out for yourself. Write the code below
Fs.readdir ("CSV", (err,files) =>{
if (ERR)
{
Console.log ("Readdir error", err);
Return
}
Console.log (files);
Let i = 0, sql = "";
function Rdfile ()
{
if (i >= files.length)
{
Console.log ("End End End--------------------------------------------------");
Fs.writefile ("Plan.sql", SQL);
Return
}
Console.log ("ReadFile", Files[i]);
SQL + = "--" + files[i "+" \ n ";
Const RL = Readline.createinterface ({input:fs.createReadStream (' csv/' +files[i],{encoding: ' UCS2 '})});
Rl.on (' line ', (LN) =>{
Let Larr = Ln.split (");
}). On (' Close ', () =>{
Console.log ("End file");
i++;
Rdfile ();
});
}
Rdfile ();
});
I'm in the CSV directory, so the CSV file
Then each file is sequentially processed into SQL statements
My CSV file is UCS2 encoded at the beginning of no setup and garbled
Look for a bit on the net originally is direct support, I also want to use Iconv
This CSV file column is a non-generic comma separated by the TAB key
Original page http://www.web-jia.com/view.php?a=35
Cyclic writes of implemented files in node. js
PHP and Ajax create advanced RSS aggregators
JSP, ASP, and PHP security programming
HTML 5 Multi-media components (video usage)
HTML5 's past, present and future
node. js Speed-Up Guide (1)
Intel is still bullish on HTML5
Create snooker Table tennis Club with HTML 5 (1)
Using node. js to develop multiplayer HTML 5 games (1)
Accessing Properties and methods
Useful PHP Components and Tutorials 21 (1)
NODEJS Read CSV