mirror of
https://github.com/danbulant/sql2csv
synced 2026-06-17 05:21:27 +00:00
Fix length v2
This commit is contained in:
parent
075a43e3aa
commit
a1d6fbc84e
1 changed files with 10 additions and 2 deletions
12
sql2csv.js
12
sql2csv.js
|
|
@ -76,8 +76,11 @@ class sql2csv {
|
||||||
column = '"' + column + '"';
|
column = '"' + column + '"';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(current != last)
|
if(current != last){
|
||||||
csv += column + ",";
|
csv += column + ",";
|
||||||
|
} else {
|
||||||
|
csv += column;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
keysEmpty = false;
|
keysEmpty = false;
|
||||||
if(self.options.crlf) csv += "\r";
|
if(self.options.crlf) csv += "\r";
|
||||||
|
|
@ -85,10 +88,15 @@ class sql2csv {
|
||||||
});
|
});
|
||||||
if(self.options.showNames){
|
if(self.options.showNames){
|
||||||
var header = "";
|
var header = "";
|
||||||
|
var current = 0;
|
||||||
|
var last = keys.length;
|
||||||
keys.forEach((key) => {
|
keys.forEach((key) => {
|
||||||
|
current++;
|
||||||
key.replace('"', '""');//double quotes, regarding https://stackoverflow.com/questions/4617935
|
key.replace('"', '""');//double quotes, regarding https://stackoverflow.com/questions/4617935
|
||||||
key.replace(",", '","');
|
key.replace(",", '","');
|
||||||
header += key + ",";
|
header += key;
|
||||||
|
if(current != last)
|
||||||
|
header += ",";
|
||||||
});
|
});
|
||||||
if(self.options.crlf) header += "\r";
|
if(self.options.crlf) header += "\r";
|
||||||
header += "\n";
|
header += "\n";
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue