Jump to content

How to get text from IE Table and Use it for future ?


jmp
 Share

Go to solution Solved by AlessandroAvolio,

Recommended Posts

Capture.thumb.PNG.32e21ee7ded2e408c0ae086d341c0c83.PNG

First excuse for bad english¬†ūüėĒ

I want to get red rounded text from ie table and save it and use it one by one

1. Get Some text from IE table, (Like 4, 9, 17 etc)

2. save it somewhere,

3. Use it one by one for future task (For Selecting  Dropdown List

HTML :

<div id="gridName">
                <table class="webgrid-table">
    <thead>
        <tr class="webgrid-header">
            <th scope="col">
No.            </th>
            <th scope="col">
Name            </th>
            <th scope="col">
Percentage            </th>
        </tr>
    </thead>
    <tbody>
        <tr class="webgrid-row-style">
            <td>1</td>
            <td>4 : ABC</td>
            <td>100</td>
        </tr>
        <tr class="webgrid-alternating-row">
            <td>2</td>
            <td>9 : DEF</td>
            <td>50</td>
        </tr>
        <tr class="webgrid-row-style">
            <td>3</td>
            <td>17 : JSE</td>
            <td>50.50</td>
        </tr>
        <tr class="webgrid-alternating-row">
            <td>4</td>
            <td>61 : XYZ</td>
            <td>64.50</td>
        </tr>
        <tr class="webgrid-row-style">
            <td>5</td>
            <td>73 : FEG</td>
            <td>72.50</td>
        </tr>
    </tbody>
    </table>

        </div>


 

image.png

Link to comment
Share on other sites

38 minutes ago, jmp said:

@AlessandroAvolio

I already tried _IETableGetCollection but it was showing whole table,  i need only some text , (Like 4, 9, 17 etc).

After getting the array that contains the whole table, extract the column of the data you are interested in with _ArrayExtract (but not required). Establish rules for identifying substring, for example by concluding that the substring you are interested in is always positioned in the first 3 characters of the string or that it is always to the left of a specific set of characters. Get the part of the string you are interested in by accessing the array and using the string manipulation functions: Stringinstr, StringMid, StringLeft etc. Create an array or set of different variables to store the new data for future use.

https://www.autoitscript.com/autoit3/docs/libfunctions/_ArrayExtract.htm

https://www.autoitscript.com/autoit3/docs/functions/String Management.htm 

 

Edited by AlessandroAvolio
Link to comment
Share on other sites

@AlessandroAvolioI have Extracted a specific row and column with _ArrayExtract,

$oTable = _IETableGetCollection ($oIE, 1)
$aTableData = _IETableWriteToArray ($oTable)
;~ $trim = StringLeft($aTableData, 2)
Local $aExtract = _ArrayExtract ($aTableData, 3, 3, 1, -1)
_ArrayDisplay($aExtract)

Now How can i Extract first 1 or 2 characters?

and 

How to save it somewhere as new data ?

Link to comment
Share on other sites

Those are very simple questions you ask me. You can save the new data by declaring an array or series of variables at the beginning of your program. You can assign them the value you get by processing strings for use in the future.

As I have already written to you, you can use Stringleft to extract the first few characters of a string. If you need to know how to access an array, read this: https://www.autoitscript.com/wiki/Arrays

Link to comment
Share on other sites

2 hours ago, AlessandroAvolio said:
#include <Array.au3>

Local $aArray[4][3] = [["aaa", "bbb", "ccc"], ["aaa", "bbb", "ccc"], ["aaa", "bbb", "ccc"], ["aaa", "bbb", "ccc"]]
Local $aSubstrings[4]

_ArrayDisplay($aArray)

For $i = 0 To UBound($aArray) - 1
    $aSubstrings[$i] = StringLeft($aArray[$i][1], 2)
Next

_ArrayDisplay($aSubstrings)

An example for you :) 

In my case Rows Count changed everytime, Then how can i use Local $aSubstrings[4] ?

Link to comment
Share on other sites

3 hours ago, AlessandroAvolio said:
#include <Array.au3>

Local $aArray[4][3] = [["aaa", "bbb", "ccc"], ["aaa", "bbb", "ccc"], ["aaa", "bbb", "ccc"], ["aaa", "bbb", "ccc"]]
Local $aSubstrings[4]

_ArrayDisplay($aArray)

For $i = 0 To UBound($aArray) - 1
    $aSubstrings[$i] = StringLeft($aArray[$i][1], 2)
Next

_ArrayDisplay($aSubstrings)

An example for you :) 

This is example for Rows.

Can you give me Example for Column ? 

Link to comment
Share on other sites

25 minutes ago, jmp said:

This is example for Rows.

Can you give me Example for Column ? 

 

#include <Array.au3>

Local $aArray[4][3] = [["a", "b", "c"], ["aa", "bb", "cc"], ["aaa", "bbb", "ccc"], ["aaaa", "bbbb", "cccc"]]
Local Const $iArrayNumberOfCols = UBound($aArray, $UBOUND_COLUMNS)
Local Const $iArrayNumberOfRows = UBound($aArray, $UBOUND_ROWS)
Local Const $iArrayColIndex = 1
Local Const $iArrayRowIndex = 2

Local $aArraySubstringsColumn[$iArrayNumberOfRows]
Local $aArraySubstringsRow[$iArrayNumberOfCols]

Local $sSubstring


_ArrayDisplay($aArray)

For $i = 0 To $iArrayNumberOfRows - 1
    $sSubstring = StringLeft($aArray[$i][$iArrayColIndex], 2)
    $aArraySubstringsColumn[$i] = $sSubstring
Next

_ArrayDisplay($aArraySubstringsColumn, "This is a col")

For $i = 0 To $iArrayNumberOfCols - 1
    $sSubstring = StringLeft($aArray[$iArrayRowIndex][$i], 2)
    $aArraySubstringsRow[$i] = $sSubstring
Next

_ArrayDisplay($aArraySubstringsRow, "This is a row")

The example already posted involved iterating a column in the array. To have the same result but on a row, simply reverse the logic of the first example. If the question seems simple to you, try first looking for a solution yourself before writing! You will become familiar with the language

Immagine.png

Edited by AlessandroAvolio
Link to comment
Share on other sites

42 minutes ago, AlessandroAvolio said:

 

#include <Array.au3>

Local $aArray[4][3] = [["a", "b", "c"], ["aa", "bb", "cc"], ["aaa", "bbb", "ccc"], ["aaaa", "bbbb", "cccc"]]
Local Const $iArrayNumberOfCols = UBound($aArray, $UBOUND_COLUMNS)
Local Const $iArrayNumberOfRows = UBound($aArray, $UBOUND_ROWS)
Local Const $iArrayColIndex = 1
Local Const $iArrayRowIndex = 2

Local $aArraySubstringsColumn[$iArrayNumberOfRows]
Local $aArraySubstringsRow[$iArrayNumberOfCols]

Local $sSubstring


_ArrayDisplay($aArray)

For $i = 0 To $iArrayNumberOfRows - 1
    $sSubstring = StringLeft($aArray[$i][$iArrayColIndex], 2)
    $aArraySubstringsColumn[$i] = $sSubstring
Next

_ArrayDisplay($aArraySubstringsColumn, "This is a col")

For $i = 0 To $iArrayNumberOfCols - 1
    $sSubstring = StringLeft($aArray[$iArrayRowIndex][$i], 2)
    $aArraySubstringsRow[$i] = $sSubstring
Next

_ArrayDisplay($aArraySubstringsRow, "This is a row")

The example already posted involved iterating a column in the array. To have the same result but on a row, simply reverse the logic of the first example. If the question seems simple to you, try first looking for a solution yourself before writing! You will become familiar with the language

Immagine.png

Thanks @AlessandroAvolio I tried it :
 

$oTable = _IETableGetCollection ($oIE, 1)
$aTableData = _IETableWriteToArray ($oTable)

Local Const $iArrayNumberOfCols = UBound($aTableData, $UBOUND_COLUMNS)
Local Const $iArrayNumberOfRows = UBound($aTableData, $UBOUND_ROWS)
Local $aArraySubstringsRow[$iArrayNumberOfCols]

;~ Local $aExtract = _ArrayExtract ($aTableData, 1, 1, 1, -1)
;~ MsgBox(0, "", $iArrayNumberOfCols)

;~ _ArrayDisplay($aExtract)
Local Const $iArrayRowIndex = 1


Local $sSubstring

For $i = 0 To $iArrayNumberOfCols - 1
    $sSubstring = StringLeft($aTableData[$iArrayRowIndex][$i], 2)
    $aArraySubstringsRow[$i] = $sSubstring
Next

_ArrayDisplay($aArraySubstringsRow, "This is a row")

But i want to skip First Col. i am changed For $i = 0 To $iArrayNumberOfCols - 1 to For $i = 1 To $iArrayNumberOfCols - 1. But it was showing Blank, Not Skipped.

Capture.PNG.76879e0b104576de2fd86c7174f925df.PNG

Link to comment
Share on other sites

@Danp2 Please give help me, i am waiting for solution.

$oTable = _IETableGetCollection ($oIE, 1)
$aTableData = _IETableWriteToArray ($oTable)

Local Const $iArrayNumberOfCols = UBound($aTableData, $UBOUND_COLUMNS)
Local Const $iArrayNumberOfRows = UBound($aTableData, $UBOUND_ROWS)
Local $aArraySubstringsRow[$iArrayNumberOfCols]

;~ Local $aExtract = _ArrayExtract ($aTableData, 1, 1, 1, -1)
;~ MsgBox(0, "", $iArrayNumberOfCols)

;~ _ArrayDisplay($aExtract)
Local Const $iArrayRowIndex = 1


Local $sSubstring

For $i = 0 To $iArrayNumberOfCols - 1
    $sSubstring = StringLeft($aTableData[$iArrayRowIndex][$i], 2)
    $aArraySubstringsRow[$i] = $sSubstring
Next

_ArrayDisplay($aArraySubstringsRow, "This is a row")

I am Extracted text using above code. Now i want to use it one by one for selecting dropdown box. 

So, how can i get one by one cell ? Please give me example of msbox.

Link to comment
Share on other sites

  • Solution
7 minutes ago, jmp said:

@Danp2 Please give help me, i am waiting for solution.


$oTable = _IETableGetCollection ($oIE, 1)
$aTableData = _IETableWriteToArray ($oTable)

Local Const $iArrayNumberOfCols = UBound($aTableData, $UBOUND_COLUMNS)
Local Const $iArrayNumberOfRows = UBound($aTableData, $UBOUND_ROWS)
Local $aArraySubstringsRow[$iArrayNumberOfCols]

;~ Local $aExtract = _ArrayExtract ($aTableData, 1, 1, 1, -1)
;~ MsgBox(0, "", $iArrayNumberOfCols)

;~ _ArrayDisplay($aExtract)
Local Const $iArrayRowIndex = 1


Local $sSubstring

For $i = 0 To $iArrayNumberOfCols - 1
    $sSubstring = StringLeft($aTableData[$iArrayRowIndex][$i], 2)
    $aArraySubstringsRow[$i] = $sSubstring
Next

_ArrayDisplay($aArraySubstringsRow, "This is a row")

I am Extracted text using above code. Now i want to use it one by one for selecting dropdown box. 

So, how can i get one by one cell ? Please give me example of msbox.

You have received replies on the topic specified in the title of the discussion. For new questions please mark the solution in this thread and open a new thread. :) 

Link to comment
Share on other sites

4 hours ago, AlessandroAvolio said:

You have received replies on the topic specified in the title of the discussion. For new questions please mark the solution in this thread and open a new thread.

I disagree. Starting a new thread just leads to a bunch of fragmentation when the discussion is essentially on the same "issue", which leads to those trying to help having to flip back and forth between the threads to have a proper understanding of what discussions have already taken place.

4 hours ago, jmp said:

Please give help me, i am waiting for solution.

IMO, you need to work on becoming more self sufficient. Many of these questions can be answered yourself by using resources such as the help file, the wiki, existing example code, etc.

Link to comment
Share on other sites

On 10/5/2021 at 7:51 PM, Danp2 said:

I disagree. Starting a new thread just leads to a bunch of fragmentation when the discussion is essentially on the same "issue", which leads to those trying to help having to flip back and forth between the threads to have a proper understanding of what discussions have already taken place.

ūüĎć

Edited by AlessandroAvolio
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...