Loop and Save to Same File

Discussions and Tech Support related to website data extraction, screen scraping and data mining using iMacros.
Forum rules
iMacros EOL - Attention!

The renewal maintenance has officially ended for Progress iMacros effective November 20, 2023 and all versions of iMacros are now considered EOL (End-of-Life). The iMacros products will no longer be supported by Progress (aside from customer license issues), and these forums will also no longer be moderated from the Progress side.

Thank you again for your business and support.

Sincerely,
The Progress Team

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
Marlon
Posts: 9
Joined: Tue Nov 20, 2007 8:27 pm

Loop and Save to Same File

Post by Marlon » Sun Feb 15, 2009 8:52 pm

Hello,

I just purchased the Pro Edition. Great stuff.

I have a very common scenario and hopefully, there is a simple and trivial solution. I have a CSV file with 2 columns. I need to LOOP through 20 rows of column 1 and EXTRACT the resulting data from each query and save the extracted data into column 2 of the same file. This has to happen 20 times.

I suppose this is asking the program to have the datasource and the download file to be the same and I don't know if this is possible.
Marcia, Tech Support

Re: Loop and Save to Same File

Post by Marcia, Tech Support » Mon Feb 16, 2009 5:11 pm

Hello,

I think you get the same result if you leave your input with one column and save both, input and extracted data on an output file.

Code: Select all

' Read input file with one column
SET !DATASOURCE Input.csv
SET !DATASOURCE_COLUMNS 1
.
.
.
' First put the input in the extract variable ...
SET !EXTRACT {{!COL1}}
' ... extracted data is appended to variable extract
TAG ... EXTRACT=TXT
' Variable extract contains both, keyword and extracted data
' Write them on output file (append) and clear
SAVEAS TYPE=EXTRACT FOLDER=* FILE=Output.csv
Would that solve your problem?
Marlon
Posts: 9
Joined: Tue Nov 20, 2007 8:27 pm

Re: Loop and Save to Same File

Post by Marlon » Mon Feb 16, 2009 9:00 pm

Marcia,

I've tried your code but extracted data is saving in column 2 of the output file. That is fine but not what I'm after. If I do this, I would have to make a copy of my input file leaving column 2 empty for the extract data. Isn't there a way to just insert extracted data into the input source file? Would this involve an external script? I hope you understand my problem. Your thoughts...
User avatar
Tech Support
Posts: 4948
Joined: Tue Sep 20, 2005 7:25 pm
Contact:

Re: Loop and Save to Same File

Post by Tech Support » Fri Feb 27, 2009 10:54 am

Isn't there a way to just insert extracted data into the input source file? Would this involve an external script?
iMacros itself can not store data in the input file, there are just to many file types and formats to make a generic solution for this case. Therefore you need an input and a output file.

However, the Scripting Interface gives you the full flexibility to do just that. Basically you need to combine
http://wiki.imacros.net/Extract-2-File.vbs with http://wiki.imacros.net/File-2-Web.vbs into one script. Our tech support can also email you a combined VBS file.

If you have the PRO Edition you can upgrade to the Scripting Edition by just paying the difference in price. You can do this directly inside the customer center at http://www.iopus.com/imacros/customers/ .
Post Reply