嗨我試圖循環通過csv並將每行存儲在JavaScript變量中。imacros無效的屬性ID
var y = {{!COL1}};
什麼是考慮
macro += "SET !DATASOURCE C:\\imacros\\demo.csv" + "\n";
macro += "SET !DATASOURCE_COLUMNS 1" + "\n";
macro += "SET !DATASOURCE_LINE {{i}}" + "\n";
嗨我試圖循環通過csv並將每行存儲在JavaScript變量中。imacros無效的屬性ID
var y = {{!COL1}};
什麼是考慮
macro += "SET !DATASOURCE C:\\imacros\\demo.csv" + "\n";
macro += "SET !DATASOURCE_COLUMNS 1" + "\n";
macro += "SET !DATASOURCE_LINE {{i}}" + "\n";
!例如:
var lines = read_file('C:\\imacros\\demo.csv');
for(var i=0;i<lines.length; i++){
alert(i + "("+lines[i].length+"): " + lines[i]);
}
function read_file(csv_file_name){
const CRLF = "\r\n";
const LF = "\n";
var lines = new Array();
var file_i = imns.FIO.openNode(csv_file_name);
var text = imns.FIO.readTextFile(file_i);
var eol = (text.indexOf(CRLF) == -1) ? LF : CRLF;
lines = text.split(eol);
return lines;
}
下面是一個典型的解決方案:在JavaScript中的iMacros的
macro += "SET !DATASOURCE C:\\imacros\\demo.csv" + "\n";
macro += "SET !DATASOURCE_LINE {{i}}" + "\n";
macro += "SET !EXTRACT {{!COL1}}" + "\n";
// ...
var y = iimGetExtract();
謝謝你會看看它,然後回來。 – BKCapri