Adding new line to extracted CSV

Discussions and Tech Support related to website data extraction, screen scraping and data mining using iMacros.

Moderators: Community Moderators, iMacros Moderators

Forum rules
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the Google search box (at the top of each forum page) to see if a similar problem or question has already been addressed. This will search the entire contents of the forums as well as the iMacros Wiki.
3. We can respond much faster to your posts if you include the following information:

CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST

Answering your own posts (e.g. attempting to "bump" your topic) drops your topic from the list of unanswered threads, so it may actually receive less views.

Adding new line to extracted CSV

by rkelly on Tue Sep 14, 2010 8:55 am

Hello -

I am extracting data from specific cells in a table, and I'm wondering if I can force a line break in the saved .CSV file. Example:

Code: Select all
<td>date</td> <td>order number</td> <td>internal number</td> <td>purchase order number</td> <td>company name</td> <td>account number</td>
<td>date</td> <td>order number</td> <td>internal number</td> <td>purchase order number</td> <td>company name></td> <td>account number</td>

etc...

As I need everything BUT the company name, my macro looks something like this:

Code: Select all
VERSION BUILD=6700624 RECORDER=FX
TAB T=1

TAG POS=1 TYPE=TD ATTR=TXT:* EXTRACT=TXT
TAG POS=2 TYPE=TD ATTR=TXT:* EXTRACT=TXT
TAG POS=3 TYPE=TD ATTR=TXT:* EXTRACT=TXT
TAG POS=4 TYPE=TD ATTR=TXT:* EXTRACT=TXT
TAG POS=6 TYPE=TD ATTR=TXT:* EXTRACT=TXT

TAG POS=7 TYPE=TD ATTR=TXT:* EXTRACT=TXT
TAG POS=8 TYPE=TD ATTR=TXT:* EXTRACT=TXT
TAG POS=9 TYPE=TD ATTR=TXT:* EXTRACT=TXT
TAG POS=10 TYPE=TD ATTR=TXT:* EXTRACT=TXT
TAG POS=12 TYPE=TD ATTR=TXT:* EXTRACT=TXT

SAVEAS TYPE=EXTRACT FOLDER=* FILE=orders_{{!NOW:dd-mm-yyyy_hhmmss}}.csv


The data is saved just fine, but I was wondering if there was some way to force a new line in the CSV file between the two rows (POS=6 and POS=7). I'm currently just getting one long row of data.

I tried adding #NEWLINE# in the gap above between POS=6 and POS=7, but that just errored out - the documentation made it seem like doing so would work.

This is my first attempt at something with iMacros, and hopefully I can get it to work!

Thanks.
rkelly
 
Posts: 1
Joined: Tue Sep 14, 2010 8:44 am

Re: Adding new line to extracted CSV

by Tom, Tech Support on Thu Sep 16, 2010 1:02 pm

Hi rkelly,

Try it like this:

Code: Select all
VERSION BUILD=6700624 RECORDER=FX
TAB T=1

TAG POS=1 TYPE=TD ATTR=TXT:* EXTRACT=TXT
TAG POS=2 TYPE=TD ATTR=TXT:* EXTRACT=TXT
TAG POS=3 TYPE=TD ATTR=TXT:* EXTRACT=TXT
TAG POS=4 TYPE=TD ATTR=TXT:* EXTRACT=TXT
TAG POS=6 TYPE=TD ATTR=TXT:* EXTRACT=TXT

SAVEAS TYPE=EXTRACT FOLDER=* FILE=orders_{{!NOW:dd-mm-yyyy_hhmmss}}.csv

TAG POS=7 TYPE=TD ATTR=TXT:* EXTRACT=TXT
TAG POS=8 TYPE=TD ATTR=TXT:* EXTRACT=TXT
TAG POS=9 TYPE=TD ATTR=TXT:* EXTRACT=TXT
TAG POS=10 TYPE=TD ATTR=TXT:* EXTRACT=TXT
TAG POS=12 TYPE=TD ATTR=TXT:* EXTRACT=TXT

SAVEAS TYPE=EXTRACT FOLDER=* FILE=orders_{{!NOW:dd-mm-yyyy_hhmmss}}.csv
Regards,

Tom, iMacros Support
Tom, Tech Support
 
Posts: 3298
Joined: Mon May 31, 2010 9:59 am

Re: Adding new line to extracted CSV

by Surprisingly_Obvious on Wed Feb 12, 2014 4:27 pm

Tom, iOpus wrote:Hi rkelly,

Try it like this:

Code: Select all
VERSION BUILD=6700624 RECORDER=FX
TAB T=1

TAG POS=1 TYPE=TD ATTR=TXT:* EXTRACT=TXT
TAG POS=2 TYPE=TD ATTR=TXT:* EXTRACT=TXT
TAG POS=3 TYPE=TD ATTR=TXT:* EXTRACT=TXT
TAG POS=4 TYPE=TD ATTR=TXT:* EXTRACT=TXT
TAG POS=6 TYPE=TD ATTR=TXT:* EXTRACT=TXT

SAVEAS TYPE=EXTRACT FOLDER=* FILE=orders_{{!NOW:dd-mm-yyyy_hhmmss}}.csv

TAG POS=7 TYPE=TD ATTR=TXT:* EXTRACT=TXT
TAG POS=8 TYPE=TD ATTR=TXT:* EXTRACT=TXT
TAG POS=9 TYPE=TD ATTR=TXT:* EXTRACT=TXT
TAG POS=10 TYPE=TD ATTR=TXT:* EXTRACT=TXT
TAG POS=12 TYPE=TD ATTR=TXT:* EXTRACT=TXT

SAVEAS TYPE=EXTRACT FOLDER=* FILE=orders_{{!NOW:dd-mm-yyyy_hhmmss}}.csv



This creates a new .csv for each line. What is needed is a single document where the 5 cells are filled horizontally, and then a new row of 5 begins on the next line down. A separate file for each line is worse for my needs than all data on one sheet with no newlines. If iMacros cannot do this without external scripting, that's the answer I need. Ty
Surprisingly_Obvious
 
Posts: 2
Joined: Wed Feb 12, 2014 4:03 pm

Re: Adding new line to extracted CSV

by iOFan on Thu Feb 13, 2014 2:07 am

Hello,
IF i understand ^^ :
For this, you have to point the same name csv file.
SAVEAS TYPE=EXTRACT FOLDER=* FILE=thesame.csv

Ex :
Code: Select all
VERSION BUILD=6700624 RECORDER=FX
TAB T=1
TAG POS=1 TYPE=TD ATTR=TXT:* EXTRACT=TXT
SAVEAS TYPE=EXTRACT FOLDER=* FILE=test.csv
TAG POS=2 TYPE=TD ATTR=TXT:* EXTRACT=TXT
SAVEAS TYPE=EXTRACT FOLDER=* FILE=test.csv
TAG POS=3 TYPE=TD ATTR=TXT:* EXTRACT=TXT
SAVEAS TYPE=EXTRACT FOLDER=* FILE=test.csv
TAG POS=4 TYPE=TD ATTR=TXT:* EXTRACT=TXT
SAVEAS TYPE=EXTRACT FOLDER=* FILE=test.csv
TAG POS=6 TYPE=TD ATTR=TXT:* EXTRACT=TXT
SAVEAS TYPE=EXTRACT FOLDER=* FILE=test.csv
TAG POS=7 TYPE=TD ATTR=TXT:* EXTRACT=TXT
SAVEAS TYPE=EXTRACT FOLDER=* FILE=test.csv
TAG POS=8 TYPE=TD ATTR=TXT:* EXTRACT=TXT
SAVEAS TYPE=EXTRACT FOLDER=* FILE=test.csv
TAG POS=9 TYPE=TD ATTR=TXT:* EXTRACT=TXT
SAVEAS TYPE=EXTRACT FOLDER=* FILE=test.csv
TAG POS=10 TYPE=TD ATTR=TXT:* EXTRACT=TXT
SAVEAS TYPE=EXTRACT FOLDER=* FILE=test.csv
TAG POS=12 TYPE=TD ATTR=TXT:* EXTRACT=TXT
SAVEAS TYPE=EXTRACT FOLDER=* FILE=test.csv
iOFan
 
Posts: 21
Joined: Tue Feb 11, 2014 3:51 am

Re: Adding new line to extracted CSV

by chivracq on Thu Feb 13, 2014 12:17 pm

It's obviously the "ss" part in Tom's Code that is causing the separate .CSV Files in "FILE=orders_{{!NOW:dd-mm-yyyy_hhmmss}}.csv", because if there is more than 1 sec between the 2 SAVEAS, then the Name will be different... So remove the "ss" and even the "mmmss" part for {{!NOW}} and you should be fine, or like iOFan suggested remove all variable parts in the File Name...
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
chivracq
 
Posts: 6472
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: Adding new line to extracted CSV

by Surprisingly_Obvious on Mon Feb 17, 2014 9:27 pm

chivracq wrote:It's obviously the "ss" part in Tom's Code that is causing the separate .CSV Files in "FILE=orders_{{!NOW:dd-mm-yyyy_hhmmss}}.csv", because if there is more than 1 sec between the 2 SAVEAS, then the Name will be different... So remove the "ss" and even the "mmmss" part for {{!NOW}} and you should be fine, or like iOFan suggested remove all variable parts in the File Name...


Excellent, thank you. That fixed it.
Surprisingly_Obvious
 
Posts: 2
Joined: Wed Feb 12, 2014 4:03 pm


Return to Data Extraction and Web Screen Scraping

Who is online

Users browsing this forum: No registered users and 3 guests

-->