AutoHotkey Community

It is currently May 27th, 2012, 2:12 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 36 posts ]  Go to page 1, 2, 3  Next
Author Message
PostPosted: February 1st, 2010, 3:25 pm 
Offline

Joined: July 6th, 2009, 9:58 pm
Posts: 678
Hello, I have data that I'd like to turn back into rows that is in a table format. Does anyone have anything that will parse this back out for me?

Code:
<TABLE>
<TR>
  <TD><tr valign="top" bgcolor="#E0F1FF"><td nowrap><img src="/icons/ecblank.gif" border="0" height="16" width="1" alt=""></td><td colspan="5" nowrap><a href="/survey_t3hwebsite.nsf/*1-SurveysGroupTrendHC?OpenPage&Start=1&Count=30&Collapse=1.1" target="_self"><img src="/icons/collapse.gif" border="0" height="16" width="16" alt="Hide details for T3h Customer / 901094"></a><font size="2" color="#0000ff" face="Arial">T3h Customer / 901094</font></td><td nowrap align="center"><b><font size="2" color="#000000" face="Arial">1403</font></b></td><td nowrap align="center"><font size="2" color="#000000" face="Arial">4.6</font></td><td nowrap align="center"><font size="2" color="#000000" face="Arial">4.6</font></td><td nowrap align="center"><font size="2" color="#000000" face="Arial">4.6</font></td><td nowrap align="center"><font size="2" color="#000000" face="Arial">4.7</font></td><td nowrap align="center"><font size="2" color="#000000" face="Arial">4.6</font></td><td nowrap align="center"><font size="2" color="#000000" face="Arial">0.0</font></td><td nowrap align="center"><font size="2" color="#000000" face="Arial">0.0</font></td><td nowrap align="center"><font size="2" color="#000000" face="Arial">0.0</font></td><td nowrap align="center"><font size="2" color="#000000" face="Arial">0.0</font></td><td nowrap align="center"><font size="2" color="#000000" face="Arial">0.0</font></td><td nowrap align="center"><font size="2" color="#000000" face="Arial">0.0</font></td><td nowrap align="center"><font size="2" color="#000000" face="Arial">0.0</font></td><td nowrap align="center"><font size="2" color="#000000" face="Arial">0.0</font></td><td nowrap><font size="2" face="Arial"></font></td><td><img src="/icons/ecblank.gif" border="0" height="16" width="1" alt=""></td></tr></TD>
</TR>

</TABLE>


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 1st, 2010, 6:40 pm 
Offline
User avatar

Joined: May 24th, 2009, 5:35 am
Posts: 2099
Location: Iowa, USA
I'm not sure exactly what you're wanting to do, but here is a script that will parse all the elements that have innerText (AHKL & COM_L):
Code:
html = ; put html from above here

doc := COM_CreateObject( "HTMLfile" )
doc.write( html )
Loop, % doc.all.length
   If ( text:=doc.all[ A_Index-1 ].innerText ) <> ""
      MsgBox, %text%

_________________
Image
Recommended: AutoHotkey_L
Basic Webpage Controls


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 1st, 2010, 6:54 pm 
Offline

Joined: July 6th, 2009, 9:58 pm
Posts: 678
Thank you for the reply,

I shall clarify, what I am looking for is something that will turn the above, which is a single table row, into a tab delimited row of the same data.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 2nd, 2010, 4:27 am 
Offline
User avatar

Joined: May 24th, 2009, 5:35 am
Posts: 2099
Location: Iowa, USA
Hmmm, seems your question is half HTML, half AHK. Beings that this is an AHK forum, could you provide the html, or example of the html, you want it changed to? Then someone could probably provide a script that would change it :wink: .

_________________
Image
Recommended: AutoHotkey_L
Basic Webpage Controls


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 2nd, 2010, 3:03 pm 
Offline

Joined: July 6th, 2009, 9:58 pm
Posts: 678
jethrow wrote:
Hmmm, seems your question is half HTML, half AHK. Beings that this is an AHK forum, could you provide the html, or example of the html, you want it changed to? Then someone could probably provide a script that would change it :wink: .


I am looking to turn it into plain text


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 2nd, 2010, 3:33 pm 
Something like this?
Code:
html =
(
; put html from above here
)

row := ""
doc := COM_CreateObject( "HTMLfile" )
doc.write( html )
Loop, % ( td:=doc.all.tags( "td" ) ).length
   If ( text:=td[ A_Index-1 ].innerText ) <> ""
      row .= text "`t"
MsgBox, % RTrim( row )


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 2nd, 2010, 5:07 pm 
Offline

Joined: July 6th, 2009, 9:58 pm
Posts: 678
Code:
#include E:\FSROOT\FILES\SCRIPTS\AutoHotKey\MODULES\com.ahk

html =
(
<TABLE>
<TR>
  <TD><tr valign="top" bgcolor="#E0F1FF"><td nowrap><img src="/icons/ecblank.gif" border="0" height="16" width="1" alt=""></td><td colspan="5" nowrap><a href="/survey_t3hwebsite.nsf/*1-SurveysGroupTrendHC?OpenPage&Start=1&Count=30&Collapse=1.1" target="_self"><img src="/icons/collapse.gif" border="0" height="16" width="16" alt="Hide details for T3h Customer / 901094"></a><font size="2" color="#0000ff" face="Arial">T3h Customer / 901094</font></td><td nowrap align="center"><b><font size="2" color="#000000" face="Arial">1403</font></b></td><td nowrap align="center"><font size="2" color="#000000" face="Arial">4.6</font></td><td nowrap align="center"><font size="2" color="#000000" face="Arial">4.6</font></td><td nowrap align="center"><font size="2" color="#000000" face="Arial">4.6</font></td><td nowrap align="center"><font size="2" color="#000000" face="Arial">4.7</font></td><td nowrap align="center"><font size="2" color="#000000" face="Arial">4.6</font></td><td nowrap align="center"><font size="2" color="#000000" face="Arial">0.0</font></td><td nowrap align="center"><font size="2" color="#000000" face="Arial">0.0</font></td><td nowrap align="center"><font size="2" color="#000000" face="Arial">0.0</font></td><td nowrap align="center"><font size="2" color="#000000" face="Arial">0.0</font></td><td nowrap align="center"><font size="2" color="#000000" face="Arial">0.0</font></td><td nowrap align="center"><font size="2" color="#000000" face="Arial">0.0</font></td><td nowrap align="center"><font size="2" color="#000000" face="Arial">0.0</font></td><td nowrap align="center"><font size="2" color="#000000" face="Arial">0.0</font></td><td nowrap><font size="2" face="Arial"></font></td><td><img src="/icons/ecblank.gif" border="0" height="16" width="1" alt=""></td></tr></TD>
</TR>

</TABLE>
)

row := ""
doc := COM_CreateObject( "HTMLfile" )
doc.write( html )
Loop, % ( td:=doc.all.tags( "td" ) ).length
   If ( text:=td[ A_Index-1 ].innerText ) <> ""
      row .= text "`t"
MsgBox, % RTrim( row )


Doesn't work, I seem to get COM errors...

Code:
Function Name:    "write"
ERROR: No COM Dispatch object!
   ()

Will Continue?
[YES] [NO]

Code:
Function Name:    "all"
ERROR: No COM Dispatch object!
   ()

Will Continue?
[YES] [NO]


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 2nd, 2010, 10:23 pm 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
Code:
com_init()
:wink:

_________________
No matter what your oppinion Please join this discussion
Formal request to Polyethene
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 2nd, 2010, 11:44 pm 
Offline

Joined: July 6th, 2009, 9:58 pm
Posts: 678
Thank you! But sorry, Tank, All I knew to add was that one line D: unf. I don't have a working COM script that I'm plugging into at this point...

Code:
com_init()
row := ""
doc := COM_CreateObject( "HTMLfile" )
doc.write( html )
Loop, % ( td:=doc.all.tags( "td" ) ).length
   If ( text:=td[ A_Index-1 ].innerText ) <> ""
      row .= text "`t"
MsgBox, % RTrim( row )


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 3rd, 2010, 12:49 am 
Offline
User avatar

Joined: May 24th, 2009, 5:35 am
Posts: 2099
Location: Iowa, USA
jethrow wrote:
I'm not sure exactly what you're wanting to do, but here is a script that will parse all the elements that have innerText (AHKL & COM_L)

Are you using AHKL & COM_L?

_________________
Image
Recommended: AutoHotkey_L
Basic Webpage Controls


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 3rd, 2010, 2:10 am 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
jethrow wrote:
jethrow wrote:
I'm not sure exactly what you're wanting to do, but here is a script that will parse all the elements that have innerText (AHKL & COM_L)

Are you using AHKL & COM_L?
whoops didnt even look at the syntax he was using your right jethrow shouldnt need COM_Init() I am betting he has wrong version of COML

_________________
No matter what your oppinion Please join this discussion
Formal request to Polyethene
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 3rd, 2010, 6:21 am 
I will search and update and try again tomorrow.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 8th, 2010, 5:17 pm 
Offline

Joined: July 6th, 2009, 9:58 pm
Posts: 678
This is working really awesome, thank you!

Is there a way to make it preserve the table lines?

For example right now I get output that is all one line, such as

Code:
Person1 10 20 30 40 50 Person2 10 20 30 40 50 Person3 10 20 30 40 50 etc


Is there a way to make it return it with the rows intact?

Code:
Person1 10 20 30 40 50
Person2 10 20 30 40 50
Person3 10 20 30 40 50
etc


I can possibly parse the data out based on types in this case but for the future it'd be really handy to have it preserve the rows.

this does not work:

Code:
row := ""
doc := COM_CreateObject( "HTMLfile" )
doc.write( html )
Loop, % ( td:=doc.all.tags( "td" ) ).length
  If ( text:=td[ A_Index-1 ].innerText ) <> ""
      row .= text "`t"
  If ( text:=td[ A_Index-1 ].innerText ) </TR> ""
      row .= text "`n"
MsgBox, % RTrim( row )


Thank you again!!!!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 8th, 2010, 5:30 pm 
Offline
User avatar

Joined: March 19th, 2008, 12:43 am
Posts: 5480
Location: the tunnel(?=light)
You'll have to change it based upon your parsing criteria, but in this case:

Code:
row := ""
doc := COM_CreateObject( "HTMLfile" )
doc.write( html )
Loop, % ( td:=doc.all.tags( "td" ) ).length
   If ( text:=td[ A_Index-1 ].innerText ) <> ""
      row .= (!row ? "" : InStr(text,"Person") ? "`n" : "`t") text
MsgBox, % RTrim( row )

_________________
Image
Try Quick Search for Autohotkey or see the tutorial for newbies.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 8th, 2010, 5:36 pm 
Offline

Joined: July 6th, 2009, 9:58 pm
Posts: 678
sinkfaze wrote:
You'll have to change it based upon your parsing criteria, but in this case:

Code:
row := ""
doc := COM_CreateObject( "HTMLfile" )
doc.write( html )
Loop, % ( td:=doc.all.tags( "td" ) ).length
   If ( text:=td[ A_Index-1 ].innerText ) <> ""
      row .= (!row ? "" : InStr(text,"Person") ? "`n" : "`t") text
MsgBox, % RTrim( row )


Thank you for the example, however topologically it's not really like that, Person1, Person2 etc could be any name. Is there any way to make it just insert an `n whenever it finds </TR> ?

Sorry to ask for so much but I'm strugging to understand what's going on with this code.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 36 posts ]  Go to page 1, 2, 3  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], Google [Bot], nimda, poserpro, rbrtryn, sjc1000, Yahoo [Bot] and 16 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group