2017-03-17 136 views
0

我有一個代碼來從csv文件導入數據到iMacros,我現在觸及的部分是iMacros正在打印excel行的值,我希望它以colulmn明智的方式打印。我得到這個錯誤,雖然我已經使用在iMacros的的{keyword !Col1}}imacros從excel中讀取

VERSION BUILD=10.4.28.1074 
'Uses a Windows script to submit several datasets to a website, e. g. for filling an online database 
' Specify input file (if !COL variables are used, IIM automatically assume a CSV format of the input file 
'CSV = Comma Separated Values in each line of the filE 
TAB T=1 
SET !DATASOURCE C:\Users\Arun\Desktop\Book2.csv 
'Start at line 2 to skip the header in the file 
SET !LOOP 1 
'Increase the current position in the file with each loop 
SET !DATASOURCE_LINE {{!LOOP}} 
' Fill web form 
URL GOTO=https://docs.google.com/forms/d/e/1FAIpQLSdDj_Rrydyd1ukk56tOL92LAu-jE9qfi1GwsAUTT1gviZNG7w/viewform?c=0&w=1 
TAG POS=1 TYPE=INPUT:EMAIL FORM=ID:mG61Hd ATTR=NAME:emailAddress CONTENT={{!COL1}} 
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:mG61Hd ATTR=NAME:entry.2005620554 CONTENT={{!COL2}} 
TAG POS=1 TYPE=INPUT:EMAIL FORM=ID:mG61Hd ATTR=NAME:entry.1045781291 CONTENT={{!COL3}} 
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:mG61Hd ATTR=NAME:entry.1065046570 CONTENT={{!COL4}} 
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:mG61Hd ATTR=NAME:entry.1166974658 CONTENT={{!COL5}} 
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:mG61Hd ATTR=NAME:entry.839337160 CONTENT={{!COL6}} 

'Note * is used to ignore leading and trailing blanks that could be in the input data 
' 
'The precent (%) symbol is used to select the stateid by VALUE as defined in the website select statement and not by its index. 

' 
'The string ($) symbol is used to select the country by TEXT, not by its index. 
'Index would be the position of an entry in the combo box list, e. g. 161 for United States 

回答

0

數據源命令加載(每個循環一個行)的總數據行明智。也許你可以重新排列你的CSV數據?

另一種解決方案是使用商業版的iMacros腳本界面創建自己的數據閱讀例程。這允許您以任何您想要的格式導入數據,然後使用iimSet將其發送到iMacros:http://wiki.imacros.net/Web_Scripting#Example_using_Windows_Scripting_Host

還有另一種解決方案是使用Kantu,它有一個免費的scripting api

1

看看下面給出的可接受的解決方法之一。假設您的CSV文件不包含任何感嘆號並且逗號作爲數據源分隔符。

' fake delimiter 
SET !DATASOURCE_DELIMITER "!" 
' real delimiter 
SET rd "," 

SET !DATASOURCE Address.csv 

SET !DATASOURCE_LINE 2 
SET row2 EVAL("'{{!COL1}}'.split('{{rd}}')[{{!LOOP}}-1];") 
SET !DATASOURCE_LINE 3 
SET row3 EVAL("'{{!COL1}}'.split('{{rd}}')[{{!LOOP}}-1];") 
SET !DATASOURCE_LINE 4 
SET row4 EVAL("'{{!COL1}}'.split('{{rd}}')[{{!LOOP}}-1];") 
' ... 

PROMPT {{row2}}<BR>{{row3}}<BR>{{row4}} 

在循環模式下播放此宏。它必須在Firefox或Chrome的'iMacros add-on'中運行。我認爲我的建議應該可以幫到你。

+0

令人驚異的解決方法;-) – Tienkamp

+0

@Tienkamp,絕對不是Sudharshaun別墅:) – Shugar