Macro does not insert data in all rows

Discussions and Tech Support related to the iMacros Google Chrome extension.
Forum rules
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information: CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
Post Reply
Juste
Posts: 5
Joined: Thu Mar 14, 2013 12:19 am

Macro does not insert data in all rows

Post by Juste » Sat Dec 02, 2017 8:39 pm

Hi Everyone,

I'm trying to fill an online Form, from CSV file. My macro is pretty much functional I'm only stuck at 2 things. I have gone through wiki and google search and tried various things such as using wild cards, record macro in different modes but nothing solved the problem.

Code: Select all

Computer info: Windows 10 (64-bit), Google Chrome Version 62.0.3202.94, Installed this http://wiki.imacros.net/iMacros_for_Chrome#Add_File_Access 
Here is my macro code:

Code: Select all

VERSION BUILD=844 RECORDER=CR
SET !DATASOURCE input.csv
SET !LOOP 2
SET !DATASOURCE_LINE {{!LOOP}}
URL GOTO=http://editProduct.php?sid=10257
TAG POS=1 TYPE=INPUT:TEXT ATTR=NAME:skuVarAmazon[] CONTENT={{!COL1}}
TAG POS=1 TYPE=INPUT:TEXT ATTR=NAME:eanVarAmazon[] CONTENT={{!COL2}}
TAG POS=1 TYPE=INPUT:TEXT ATTR=NAME:colorAmazon[] CONTENT={{!COL3}}
TAG POS=2 TYPE=INPUT:TEXT ATTR=NAME:skuVarAmazon[] CONTENT={{!COL1}}
TAG POS=2 TYPE=INPUT:TEXT ATTR=NAME:eanVarAmazon[] CONTENT={{!COL2}}
TAG POS=2 TYPE=INPUT:TEXT ATTR=NAME:colorAmazon[] CONTENT={{!COL3}}
What I am trying to achieve?
1- Macro get data from CSV file and fill the web page Form. All rows on online Form should fill one by one then macro should stop working after filling all the rows and columns.

2- The online Form URL is same except the end of URL such as: 15421 This part is different for other similar pages. For example: product Apple URL is http://editProduct.php?sid=10257 and product Banana URL is http://editProduct.php?sid=65103

What I am getting after running my macro?
1- My macro does not insert data in all rows. Macro is only inserting CSV first row data into all rows of online Form. I have tried Play and Play (Loop), also tried wild card but nothing worked. To me it seems that every ATTR is same for each row on web page may be that's why data is not being inserted in all rows?

2- I don't want to change the URL again and again. Tried wild card such as http://editProduct.php?sid=* but not working. Is there any way that my macro work for all URL's which are same except the end part of URL.

Does anyone know how to solve these?

Thanks in advance.
chivracq
Posts: 8765
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Macro does not insert data in all rows

Post by chivracq » Sun Dec 03, 2017 1:27 pm

Juste wrote:Hi Everyone,

I'm trying to fill an online Form, from CSV file. My macro is pretty much functional I'm only stuck at 2 things. I have gone through wiki and google search and tried various things such as using wild cards, record macro in different modes but nothing solved the problem.

Code: Select all

Computer info: 
Windows 10 (64-bit), 
Google Chrome Version 62.0.3202.94, 
Installed this http://wiki.imacros.net/iMacros_for_Chrome#Add_File_Access 
Here is my macro code:

Code: Select all

VERSION BUILD=844 RECORDER=CR
SET !DATASOURCE input.csv
SET !LOOP 2
SET !DATASOURCE_LINE {{!LOOP}}
URL GOTO=http://editProduct.php?sid=10257
TAG POS=1 TYPE=INPUT:TEXT ATTR=NAME:skuVarAmazon[] CONTENT={{!COL1}}
TAG POS=1 TYPE=INPUT:TEXT ATTR=NAME:eanVarAmazon[] CONTENT={{!COL2}}
TAG POS=1 TYPE=INPUT:TEXT ATTR=NAME:colorAmazon[] CONTENT={{!COL3}}
TAG POS=2 TYPE=INPUT:TEXT ATTR=NAME:skuVarAmazon[] CONTENT={{!COL1}}
TAG POS=2 TYPE=INPUT:TEXT ATTR=NAME:eanVarAmazon[] CONTENT={{!COL2}}
TAG POS=2 TYPE=INPUT:TEXT ATTR=NAME:colorAmazon[] CONTENT={{!COL3}}
What I am trying to achieve?
1- Macro get data from CSV file and fill the web page Form. All rows on online Form should fill one by one then macro should stop working after filling all the rows and columns.

2- The online Form URL is same except the end of URL such as: 15421 This part is different for other similar pages. For example: product Apple URL is http://editProduct.php?sid=10257 and product Banana URL is http://editProduct.php?sid=65103

What I am getting after running my macro?
1- My macro does not insert data in all rows. Macro is only inserting CSV first row data into all rows of online Form. I have tried Play and Play (Loop), also tried wild card but nothing worked. To me it seems that every ATTR is same for each row on web page may be that's why data is not being inserted in all rows?

2- I don't want to change the URL again and again. Tried wild card such as http://editProduct.php?sid=* but not working. Is there any way that my macro work for all URL's which are same except the end part of URL.

Does anyone know how to solve these?

Thanks in advance.
The 'General' Sub-Forum would have been the "correct" Sub-Forum for this Thread as the 'iMacros for CR' Sub-Forum is meant for Threads specific to iMacros for CR only..., but OK,never mind, and no need to duplicate now...

Well..., if I understand your Case correctly, the Pb comes from the 'URL GOTO' which will keep reloading the 'Apple' Product Page as you've hard-coded the 'Product_ID' "=10257" in your Script.
iMacros always records the ''URL GOTO' of the Page where you start the Recording but you then later can edit this 'URL GOTO' Statement if you want to make it "generic" or "dynamic" or even comment it out if you don't want the Page to be reloaded on each Run or Loop...

=> What you'd need is to include the 'Product_ID' for each Product in your '.CSV' in a 4th Column, and you can then loop your Script with:

Code: Select all

URL GOTO=http://editProduct.php?sid={{!COL4}}
Or you can store the whole URL in 'COL_4', then you would use:

Code: Select all

URL GOTO={{!COL4}}
You could comment out or delete the 'URL GOTO' Line if you prefer to load each 'Product' Page manually, but it will then be a bit more "complicated' for the Looping to be "synchronize" with your '.CSV' File for the Script to "know" which Row to pick from your 'CSV', corresponding to the specific 'Product' Page you will be on...

And nope, you cannot use a Wildcard for 'URL GOTO', the Browser needs to know exactly to which URL you want to go...

:!: Hum..., and watch out, you are on CR, and I think that iMacros for CR requires your Script to specify the Nb of Cols in your '.CSV' with '!DATASOURCE_COLUMNS'... Unless v8.4.4 for CR is maybe able now to auto-detect it like all other Versions for all other Browsers do, but the Wiki (still) mentions that this Command is required for CR...
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
chivracq
Posts: 8765
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Macro does not insert data in all rows

Post by chivracq » Sun Dec 03, 2017 2:12 pm

Oh yeah...!, but I see in your Script that you reuse the same '{{!COL1}}' - '{{!COL3}}' (on the same Row) for 2 different Input Fields each time (with 'POS=1' and 'POS=2')..., so I guess this is what is going "wrong" in your Script, ah-ah...!

Well, difficult to tell you, I don't know what Data you've got in your '.CSV', and how the Data is "organized", but if those 6 Input Fields expect different Values, you must organize your 'CSV' with 6 Columns instead of only 3 Cols..., or if each Product has its corresponding Data organized as 3 Cols on 2 Rows, then you need to increment '!DATASOURCE_LINE' to tell iMacros to fetch the Data from the next Row for the 3 'TAG POS=2' Statements...
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
Juste
Posts: 5
Joined: Thu Mar 14, 2013 12:19 am

Re: Macro does not insert data in all rows

Post by Juste » Sun Dec 03, 2017 6:42 pm

chivracq wrote:Oh yeah...!, but I see in your Script that you reuse the same '{{!COL1}}' - '{{!COL3}}' (on the same Row) for 2 different Input Fields each time (with 'POS=1' and 'POS=2')..., so I guess this is what is going "wrong" in your Script, ah-ah...!

Well, difficult to tell you, I don't know what Data you've got in your '.CSV', and how the Data is "organized", but if those 6 Input Fields expect different Values, you must organize your 'CSV' with 6 Columns instead of only 3 Cols..., or if each Product has its corresponding Data organized as 3 Cols on 2 Rows, then you need to increment '!DATASOURCE_LINE' to tell iMacros to fetch the Data from the next Row for the 3 'TAG POS=2' Statements...
Thank you for the reply. I apologize for posting in different forum didn't knew about it.

Let me explain more: I am sharing two screen shots for your better understanding.

1- Earlier I was using !DATASOURCE_COLUMNS but chrome macros is auto picking columns of .CSV and my requirement right now is 3 columns.

Yes, all input fields require different values. I'm using same COL1, COL2, COL3 because data is organized in rows, it is huge data filled in rows instead of columns. Each row have different values/data.

If I use '!DATASOURCE_LINE' it will just kill the purpose of using macros. For example I have 50 rows if I edit '!DATASOURCE_LINE' each time it will require me to edit macros 50 times and add number like !DATASOURCE_LINE 4, !DATASOURCE_LINE 5 every time.

2- I have to manually open each URL separately to fill the form. Basically URL is same for each product with some differences in the form. The ID/number generated at the end of URL is generated by server/web page, it is not set by me. If I copy paste each ID/number of URL into 4th column of .CSV it will take a lot of time since I have to open each URL of each product manually.

Screenshots:

First screenshot is of how data is organized in excel and needs to be fill. Second screenshot is of my online form.

Image
Image
chivracq
Posts: 8765
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Macro does not insert data in all rows

Post by chivracq » Sun Dec 03, 2017 8:18 pm

Juste wrote:Thank you for the reply. I apologize for posting in different forum didn't knew about it.

Let me explain more: I am sharing two screen shots for your better understanding.

1- Earlier I was using !DATASOURCE_COLUMNS but chrome macros is auto picking columns of .CSV and my requirement right now is 3 columns.

Yes, all input fields require different values. I'm using same COL1, COL2, COL3 because data is organized in rows, it is huge data filled in rows instead of columns. Each row have different values/data.

If I use '!DATASOURCE_LINE' it will just kill the purpose of using macros. For example I have 50 rows if I edit '!DATASOURCE_LINE' each time it will require me to edit macros 50 times and add number like !DATASOURCE_LINE 4, !DATASOURCE_LINE 5 every time.

2- I have to manually open each URL separately to fill the form. Basically URL is same for each product with some differences in the form. The ID/number generated at the end of URL is generated by server/web page, it is not set by me. If I copy paste each ID/number of URL into 4th column of .CSV it will take a lot of time since I have to open each URL of each product manually.

Screenshots:

First screenshot is of how data is organized in excel and needs to be fill. Second screenshot is of my online form.

Image
Image
Ah OK, yep, I think I understand better now thanks to the Screenshots...
=> Well then, simply loop your Script per Row without the 'URL GOTO':

Code: Select all

VERSION BUILD=844 RECORDER=CR
SET !DATASOURCE input.csv
SET !LOOP 2
SET !DATASOURCE_LINE {{!LOOP}}
SET Input_LOOP {{!DATASOURCE_LINE}}
ADD Input_LOOP -1
'URL GOTO=http://editProduct.php?sid=10257

TAG POS={{Input_LOOP}} TYPE=INPUT:TEXT ATTR=NAME:skuVarAmazon[] CONTENT={{!COL1}}
TAG POS={{Input_LOOP}} TYPE=INPUT:TEXT ATTR=NAME:eanVarAmazon[] CONTENT={{!COL2}}
TAG POS={{Input_LOOP}} TYPE=INPUT:TEXT ATTR=NAME:colorAmazon[] CONTENT={{!COL3}}
And you simply loop it 5 times... (but you need to specify "6" in the Loop_Max Field because of the Header in your '.CSV'...)
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
Juste
Posts: 5
Joined: Thu Mar 14, 2013 12:19 am

Re: Macro does not insert data in all rows

Post by Juste » Tue Dec 05, 2017 8:05 pm

=> Well then, simply loop your Script per Row without the 'URL GOTO':

Code: Select all

VERSION BUILD=844 RECORDER=CR
SET !DATASOURCE input.csv
SET !LOOP 2
SET !DATASOURCE_LINE {{!LOOP}}
SET Input_LOOP {{!DATASOURCE_LINE}}
ADD Input_LOOP -1

TAG POS={{Input_LOOP}} TYPE=INPUT:TEXT ATTR=NAME:skuVarAmazon[] CONTENT={{!COL1}}
TAG POS={{Input_LOOP}} TYPE=INPUT:TEXT ATTR=NAME:eanVarAmazon[] CONTENT={{!COL2}}
TAG POS={{Input_LOOP}} TYPE=INPUT:TEXT ATTR=NAME:colorAmazon[] CONTENT={{!COL3}}
And you simply loop it 5 times... (but you need to specify "6" in the Loop_Max Field because of the Header in your '.CSV'...)
Excellent! It is working now bundle of thanks for the support much appreciated. Can you kindly tell me what does all "Input_Loop's" in above mentioned code do? How it actually work? I'm trying to understand the logic.
chivracq
Posts: 8765
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Macro does not insert data in all rows

Post by chivracq » Tue Dec 05, 2017 8:41 pm

Juste wrote:Excellent! It is working now bundle of thanks for the support much appreciated. Can you kindly tell me what does all "Input_Loop's" in above mentioned code do? How it actually work? I'm trying to understand the logic.
OK, good to hear, and Thanks for the Feedback... :D

There is nothing complicated btw, it is a very "Standard" Use of iMacros with a looping Script...
The only mini-Difficulty was that your Row_1=POS_1 on the Web-Form is using Data from Row_2 in your DataSource, then Row_2=POS_2 on the Web-Form is using Data from Row_3 in the DS, etc...
Normally you would use "TAG POS={{!LOOP}}" for filling in your Form when looping the Script but because the Rows/POS on the Form not being synced with the Rows in the DS, I had to "adjust" with "-1" between the two, hence the Use of a Var that I called "Input_LOOP" but I could have given it any Name, or used '!VAR1'... :wink:
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
Juste
Posts: 5
Joined: Thu Mar 14, 2013 12:19 am

Re: Macro does not insert data in all rows

Post by Juste » Thu Dec 07, 2017 9:51 pm

chivracq wrote:
Juste wrote:Excellent! It is working now bundle of thanks for the support much appreciated. Can you kindly tell me what does all "Input_Loop's" in above mentioned code do? How it actually work? I'm trying to understand the logic.
OK, good to hear, and Thanks for the Feedback... :D

There is nothing complicated btw, it is a very "Standard" Use of iMacros with a looping Script...
The only mini-Difficulty was that your Row_1=POS_1 on the Web-Form is using Data from Row_2 in your DataSource, then Row_2=POS_2 on the Web-Form is using Data from Row_3 in the DS, etc...
Normally you would use "TAG POS={{!LOOP}}" for filling in your Form when looping the Script but because the Rows/POS on the Form not being synced with the Rows in the DS, I had to "adjust" with "-1" between the two, hence the Use of a Var that I called "Input_LOOP" but I could have given it any Name, or used '!VAR1'... :wink:
Thanks. If I remove the header in .CSV and don't want to use the header row, then the Form POS=1 or Form Row 1 will pick Row 1 of .CSV so in this case what should be my code?
chivracq
Posts: 8765
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Macro does not insert data in all rows

Post by chivracq » Thu Dec 07, 2017 10:58 pm

Juste wrote:Thanks. If I remove the header in .CSV and don't want to use the header row, then the Form POS=1 or Form Row 1 will pick Row 1 of .CSV so in this case what should be my code?
Well, then that's the "simplest" Case, then '!DATASOURCE_LINE' + 'POS=n' for your 3x 'TAG' Input Fields are synchronized and you can simply use the raw "{{!LOOP}}" everywhere... And your Script would then become...:

Code: Select all

VERSION BUILD=844 RECORDER=CR
SET !DATASOURCE input.csv
SET !LOOP 1
SET !DATASOURCE_LINE {{!LOOP}}

TAG POS={{!LOOP}} TYPE=INPUT:TEXT ATTR=NAME:skuVarAmazon[] CONTENT={{!COL1}}
TAG POS={{!LOOP}} TYPE=INPUT:TEXT ATTR=NAME:eanVarAmazon[] CONTENT={{!COL2}}
TAG POS={{!LOOP}} TYPE=INPUT:TEXT ATTR=NAME:colorAmazon[] CONTENT={{!COL3}}
The 'SET !LOOP 1' Statement is not even needed as it is already the Default, but I find it "Good Practice" to keep it as it tells you already from your iMacros Script that your DataSource doesn't have any Header and that the Data starts from Row_1..., and if you want to create another similar Script, then you won't forget about this Statement if the new DataSource does have a Header..., ah-ah...!
And one more Advantage is that, if for any Reason, stg went wrong at say Row_25 (=!LOOP_25) and your Script aborted and didn't complete the 3x 'POS=25' Statements, then you can run your Macro again with a "SET !LOOP 25", and it will start again from Row_25, without doing Rows_[1-24] again... 8)
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
Juste
Posts: 5
Joined: Thu Mar 14, 2013 12:19 am

Re: Macro does not insert data in all rows

Post by Juste » Sun Dec 10, 2017 9:43 pm

chivracq wrote:
Juste wrote:Thanks. If I remove the header in .CSV and don't want to use the header row, then the Form POS=1 or Form Row 1 will pick Row 1 of .CSV so in this case what should be my code?
Well, then that's the "simplest" Case, then '!DATASOURCE_LINE' + 'POS=n' for your 3x 'TAG' Input Fields are synchronized and you can simply use the raw "{{!LOOP}}" everywhere... And your Script would then become...:

Code: Select all

VERSION BUILD=844 RECORDER=CR
SET !DATASOURCE input.csv
SET !LOOP 1
SET !DATASOURCE_LINE {{!LOOP}}

TAG POS={{!LOOP}} TYPE=INPUT:TEXT ATTR=NAME:skuVarAmazon[] CONTENT={{!COL1}}
TAG POS={{!LOOP}} TYPE=INPUT:TEXT ATTR=NAME:eanVarAmazon[] CONTENT={{!COL2}}
TAG POS={{!LOOP}} TYPE=INPUT:TEXT ATTR=NAME:colorAmazon[] CONTENT={{!COL3}}
The 'SET !LOOP 1' Statement is not even needed as it is already the Default, but I find it "Good Practice" to keep it as it tells you already from your iMacros Script that your DataSource doesn't have any Header and that the Data starts from Row_1..., and if you want to create another similar Script, then you won't forget about this Statement if the new DataSource does have a Header..., ah-ah...!
And one more Advantage is that, if for any Reason, stg went wrong at say Row_25 (=!LOOP_25) and your Script aborted and didn't complete the 3x 'POS=25' Statements, then you can run your Macro again with a "SET !LOOP 25", and it will start again from Row_25, without doing Rows_[1-24] again... 8)
Great explanation. Once again thank you for the the help.
chivracq
Posts: 8765
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Macro does not insert data in all rows

Post by chivracq » Sun Dec 10, 2017 10:21 pm

Juste wrote:Great explanation. Once again thank you for the the help.
Good...! I'm glad if you understood the "Principle"...! :D
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
Post Reply