Jump to content

create folder using name from a table


Tosyk
 Share

Recommended Posts

hi! I have a txt table with IDs:

firstnameid    lastnameid    playerid    
0    13572    146
1116    27965    27965
26439    16049    16049
<...>

I have another txt table with names where 'nameid' is basically the 'firstnameid' and 'lastnameid' from the first table:

name    nameid
K Jacobsen    1116
Al Yousif    26439
A. Alcaraz    27965
Alsultan    16049
<...>

additionally I have a txt file with a list of IDs:

27965
146
16049
<...>

I want to drop this txt file on a script so it can produce a list of folder with names like:
"..\players\0 13572\"
"..\players\K Jacobsen A. Alcaraz\"
"..\players\Al Yousif A. Alsultan\"

is it possible to do so with autoit?

Edited by Tosyk
Link to comment
Share on other sites

_FileReadToArray() may be an option for you.  You can read your table text file into an array and split it into cols/rows (dimensions). 

Then you can iterate through the array and use DirCreate to create the folders.

 

What is everyone playing?

Link to comment
Share on other sites

12 hours ago, spudw2k said:

_FileReadToArray() may be an option for you.  You can read your table text file into an array and split it into cols/rows (dimensions). 

Then you can iterate through the array and use DirCreate to create the folders.

 

What is everyone playing?

I'm not really good at codding. I don't know where to start. Especially interesting how to read values with number from another table 

Link to comment
Share on other sites

How are your table text files being produced?  Where do they come from?

If they are generated by a database, perhaps you could create a query to prepare the data how you want first to simplify things. 

Can you give more details of where the data comes from?

Link to comment
Share on other sites

started to make a script:

Local $arr
           Local $sPlayersTbl = 'players2.txt'
           Local $sSourceFile = 'chars.txt'
           _FileReadToArray($sPlayersTbl, $arr, $FRTA_ENTIRESPLIT, "    ")
           _ArrayDisplay($arr)

        If FileExists($sSourceFile) Then
           Local $arr
           _FileReadToArray($sSourceFile, $arr)
;~         _ArrayDisplay($arr)

         If IsArray($arr) Then
             For $i = 1 to $arr[0]
                 ConsoleWrite($arr[$i] & @LF)
;~               here will be further operations
             Next
         EndIf

now I'm interesting how to search for specific IDs in column 'playerid' of players2.txt table and return 2 values for each ID: from 'firstnameid' and 'lastnameid' columns of the same line inside players2.txt.

chars.txt

Edited by Tosyk
Link to comment
Share on other sites

Here is something to start with for you ...

#include <Array.au3>
#include <File.au3>

Local $arr
Local $sPlayersTbl = 'players2.txt'
Local $sSourceFile = 'chars.txt'
_FileReadToArray($sPlayersTbl, $arr, $FRTA_ENTIRESPLIT, @TAB)
_ArrayDisplay($arr)

If FileExists($sSourceFile) Then
;~  Local $arr
;~  _FileReadToArray($sSourceFile, $arr)
;~         _ArrayDisplay($arr)

    If IsArray($arr) Then
        For $i = 1 To UBound($arr) - 1
            ConsoleWrite('line ' & $i & ': ' & $arr[$i][0] & ' -> ' & $arr[$i][1] & @CRLF)
;~               here will be further operations
        Next
    EndIf
EndIf

output:

Quote

line 1: 0 -> 13572
line 2: 1116 -> 27965
line 3: 26439 -> 16049
line 4: 26583 -> 10990
line 5: 14024 -> 19664
line 6: 3479 -> 20801
line 7: 4923 -> 33599

 

Edited by Zedna
Link to comment
Share on other sites

Here is further example:

#include <Array.au3>
#include <File.au3>

Local $arr
Local $sPlayersTbl = 'players2.txt'
Local $sSourceFile = 'chars.txt'
_FileReadToArray($sPlayersTbl, $arr, $FRTA_ENTIRESPLIT, @TAB)
_ArrayDisplay($arr) ; 2D array

If FileExists($sSourceFile) Then
    Local $arr2
    _FileReadToArray($sSourceFile, $arr2)
    _ArrayDisplay($arr2) ; 1D array

    If IsArray($arr2) And IsArray($arr) Then
        For $i = 1 To UBound($arr2) - 1
            $id = $arr2[$i]
            $id2 = 'not found'
            For $j = 1 To UBound($arr) - 1
                If $arr[$j][1] = $id Then ; find ID2 from players2.txt
                    $id2 = $arr[$j][0]
                    ExitLoop
                EndIf
            Next
            ConsoleWrite('source line ' & $i & ': ' & $id & ' -> ' & $id2 & @CRLF)
        Next
    EndIf
EndIf

 

 

Quote

source line 1: 242703 -> not found
source line 2: 20801 -> 3479

 

Edited by Zedna
Link to comment
Share on other sites

1 hour ago, Zedna said:

In your posted TXT files there is no such column "name".

because I didn't attached this file. but I described it in the first post.

also your script is addressing the munber of column but at this point I'm interesting how to address the name of the column. do you know how to do that?

Link to comment
Share on other sites

as far as I understand with this code:

If $arr[$j][1] = $id Then ; find ID2 from players2.txt
  $id2 = $arr[$j][0]
  ExitLoop
EndIf

you are looking for the ID (given by chars.txt) in second column of players2.txt and return the value from first column.

but how to look fo ID in column with name 'playerid' and if found then return values from 'firstnameid' and 'lastnameid' columns of the same line inside players2.txt?

Edited by Tosyk
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...