Tosyk Posted September 14, 2021 Posted September 14, 2021 (edited) 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 September 14, 2021 by Tosyk
spudw2k Posted September 14, 2021 Posted September 14, 2021 _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? Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF
Tosyk Posted September 15, 2021 Author Posted September 15, 2021 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
spudw2k Posted September 16, 2021 Posted September 16, 2021 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? Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF
Tosyk Posted September 16, 2021 Author Posted September 16, 2021 (edited) 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 September 16, 2021 by Tosyk
Zedna Posted September 16, 2021 Posted September 16, 2021 (edited) 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 September 16, 2021 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search
Zedna Posted September 16, 2021 Posted September 16, 2021 (edited) 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 September 16, 2021 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search
Tosyk Posted September 16, 2021 Author Posted September 16, 2021 (edited) the question was more like how to read the column "name" and then return a value from that column on the same line. sometimes columns may have other order Edited September 16, 2021 by Tosyk
Zedna Posted September 16, 2021 Posted September 16, 2021 (edited) In your posted TXT files there is no such column "name". So you can take my script and its concept and accomodate it to your real TXT files ... Edited September 16, 2021 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search
Tosyk Posted September 16, 2021 Author Posted September 16, 2021 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?
Zedna Posted September 16, 2021 Posted September 16, 2021 As you can see in result of _ArrayDisplay: names of columns (in 2D array) are in Row 0 $arr[0][0], $arr[0][1], $arr[0][2], ... Resources UDF ResourcesEx UDF AutoIt Forum Search
Tosyk Posted September 16, 2021 Author Posted September 16, 2021 (edited) 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 September 16, 2021 by Tosyk
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now