CSV数据导入Javascript并在字符串包含数据时运行exe

CSV数据导入Javascript并在字符串包含数据时运行exe

本文介绍了将.CSV数据导入Javascript并在字符串包含数据时运行execute的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有几个iMacro文件,用一个javascript文件执行。

I have a couple of iMacro-files, that is executed with a single javascript file.

非常基本,看起来像这样。

Very basic, looks like this.

iimPlay("GoogleMacro.iim");
iimPlay("IBMMacro.iim");
iimPlay("IMDBMacro.iim");
iimPlay("AltavistaMacro.iim");
iimPlay("GametrailersMacro.iim");
iimPlay("MortalCombatMacro.iim");
iimPlay("WikipediaMacro.iim");

它被称为 playme.js ,效果非常好。

It is called playme.js, and works really good.

但是,每次启动.js文件时,我都不想运行每个宏。

Though, I don't want to run every macro each time I launch the .js file.

我有一个单独的CSV文件, urldata.csv

I have a separate CSV-file, urldata.csv

URLINFO,URLINFO2,DATA1,DATA2
http://google.com,GOOGLE,"hello","thank you for searching"
http://ibm.com,IBM,null,null
http://imdb.com,IMDB,null,null
http://altavista.com,ALTAVISTA,"rip","rest in peace, my friend",
http://gametrailers.com,GAMETRAILERS,null,null
http://mortalkombat.wikia.com,MORTALKOMBAT,null,null
http://wikipedia.org,WIKIPEDIA,null,null

我想要它的工作方式,在这种情况下(上面的数据) urldata.csv ),。js文件只执行GoogleMacro.iim和AltavistaMacro.iim

The way I want it to work, in this case (the data above in urldata.csv), the .js file would only execute GoogleMacro.iim and AltavistaMacro.iim

我正在寻找的规则:如果COL3具有该值 null ,请勿使用iimPlay,并检查下一个文件。

The rule I am looking for: If COL3 has the value null, do not iimPlay, and check the next file in line.

.JS代码工作(我非常清楚这只是胡言乱语:这样:

The .JS code should work (I am very aware of this is just gibberish) like this:

#Import urldata.csv

Loop whole CSV {
ROW2, If COL3 = null --> go to ROW3
else iimPlay("GoogleMacro.iim");
ROW3, If COL3 = null --> go to ROW4
else iimPlay("IBMMacro.iim");
Etc..
}

我需要弄明白:


  • 如何将 urldata.csv 中的数据导入/读取到我的 playme.js 。显然,免费版的iMacros中不允许使用因此我不能使用它。

  • 如果行X上的值不是null,如何制作仅使用iiPlay的函数。

  • How to import/read the data from urldata.csv to my playme.js. Apparently, jQuery is not allowed in the free version of iMacros and therefore I cannot use this.
  • How to make a function that only use iiPlay if the value on row X is something else than null.

请帮忙! :)

推荐答案

解决了!

将.csv更改为以下内容:

Changed the .csv to the following:

"http://google.com",GoogleMacro,"hello","thank you for searching"
"http://ibm.com",IBMMacro,"",""
"http://imdb.com",IMDBMacro,"",""
"http://altavista.com,ALTAVISTAMacro","rip","rest in peace, my friend",
"http://gametrailers.com",GAMETRAILERSMacro,"",""
"http://mortalkombat.wikia.com",MORTALKOMBATMacro,"",""
"http://wikipedia.org",WIKIPEDIAMacro,"",""

并获得了一些非常好的帮助.js

And got some really good help with the .js

var load;
load =  "CODE:";
load +=  "SET !DATASOURCE urldata.csv" + "\n";
load +=  "SET !DATASOURCE_COLUMNS 4" + "\n";
load +=  "SET !DATASOURCE_LINE {{i}}" + "\n";
load +=  "SET !extract {{!col2}}" + "\n";
load +=  "ADD !extract {{!col3}}" + "\n";

var siteName = "";
var siteContent = "";

//Change 4 to the number of websites
for(i=1;i<4;i++) {

  iimSet("i",i);
  // Load data
  iimPlay(load);
  siteName = iimGetLastExtract(1);

  // Check if the website has content
  siteContent = iimGetLastExtract(2);

  if(siteName != "Website" && siteContent != "") {
     iimPlay(siteName + '.iim');
  } else {
  }

 }

这篇关于将.CSV数据导入Javascript并在字符串包含数据时运行execute的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 16:28