Jump to content

Recommended Posts

Posted (edited)

Hi all, 
 
 I need your help to learn how can I implement the data structure as described in the attachment

Thanks!

post-56238-0-24191500-1394373014_thumb.j

Edited by dushkin
  • Moderators
Posted

dushkin,

Looks like an ini file will suffice: :)

[Item 1]
Key=Val
Key=Val
Key=Val
Key=Val
[Item 2]
Key=Val
Key=Val
[Item 3]
Key=Val
Key=Val
Key=Val
M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

  • Moderators
Posted

dushkin,

I see. Then perhaps an array of arrays: :)

; 3 "Item"s
$aData_Outer[4]

; Now add the "Key/Val" pairs as arrays held within each item
$aData_Outer[1] = $aData_Inner_1[5][2]
;$aData_inner_1[1][0] = Key1
$aData_inner_1[1][1] = Value1
$aData_inner_1[2][0] = Key2
$aData_inner_1[2][1] = Value2
$aData_inner_1[3][0] = Key3
$aData_inner_1[3][1] = Value3
$aData_inner_1[4][0] = Key4
$aData_inner_1[5][1] = Value4
;
$aData_Outer[2] = $aData_Inner_2[3][2]
$aData_inner_2[1][0] = Key1
$aData_inner_2[1][1] = Value1
$aData_inner_2[2][0] = Key2
$aData_inner_2[2][1] = Value2
;
$aData_Outer[3] = $aData_Inner_1[4][2]
$aData_inner_3[1][0] = Key1
$aData_inner_3[1][1] = Value1
$aData_inner_3[2][0] = Key2
$aData_inner_3[2][1] = Value2
$aData_inner_3[3][0] = Key3
$aData_inner_3[3][1] = Value3
M23

;

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

Posted

could you post a "sample" of the data you need to load from the file?

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Posted (edited)

Melba - Thanks. I will considerate it.

Pinco - suppose I want to read from a file that holds the list of all car vendors that sells in a certain country, and then the models and their prices.

So, for example:

Honda

Civic-50000

Toyota

Corolla - 40000

Yaris - 25000

Hyundai

i30-30000

i35-40000

etc.

The number of the vendors and the models are unknown, unless I perform 2 passes on the file (and I prefer not to)

Thanks.

Edited by dushkin
Posted (edited)

Thanks Firefox. It is an HTML. The values are not in english, and even not in latin charachters :-)

Will it still be helpfull?

Aren't the concept and the example clear enough?

Edited by dushkin
Posted (edited)

An array example was given to you, which is exactly what you're looking for.

For the unknown count, use ReDim if necessary with a step; but since it's a html, I'm not sure it will be necessary.

I asked you this if you want us to build you a full working example.

Br, FireFox.

Edited by FireFox
Posted

All, thank you for your kind help.

Mmmm, If I will just send the html file, and I will specify the tags that surround the values I need - will it suffice?

Posted
  On 3/9/2014 at 2:48 PM, dushkin said:

and I will specify the tags that surround the values I need - will it suffice?

Sure :)

Posted
  On 3/9/2014 at 2:24 PM, dushkin said:

Melba - Thanks. I will considerate it.

Pinco - suppose I want to read from a file that holds the list of all car vendors that sells in a certain country, and then the models and their prices.

So, for example:

Honda

Civic-50000

Toyota

Corolla - 40000

Yaris - 25000

Hyundai

i30-30000

i35-40000

etc.

The number of the vendors and the models are unknown, unless I perform 2 passes on the file (and I prefer not to)

Thanks.

 

something like this could do

#include <File.au3>
#include <array.au3>
Local $output[1][2], $x = 0, $i
Local $aArray
_FileReadToArray(".\data.txt", $aArray)
; _ArrayDisplay($aArray)
For $i = 1 To $aArray[0]
    ; check for empty lines
    If StringStripWS(StringStripCR($aArray[$i]), 7) <> "" Then
        If Not StringInStr($aArray[$i], "-") Then
            ReDim $output[UBound($output)][$x + 2]
            $output[0][$x] = StringStripWS($aArray[$i], 3)
            $x += 2 ; will be next column
            $y = 1
        Else
            If $y = UBound($output) Then
                ReDim $output[UBound($output) + 1][UBound($output, 2)]
            EndIf
            $temp = StringSplit($aArray[$i], "-", 2)
            $output[$y][$x - 2] = StringStripWS($temp[0], 3)
            $output[$y][$x - 1] = StringStripWS($temp[1], 3)
            $y += 1
        EndIf
    EndIf
Next
_ArrayDisplay($output)

anyway, if data is on an internet site, then you could grab data directly from the web page using _ie* function instead of pass through disk files

Bye

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

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
×
×
  • Create New...