Rei10 Posted January 17, 2020 Posted January 17, 2020 There are 3 data files. I want to calculate how much quantity each type of cell. For example: hare == 2, wolf==2,bear==5. 1.txt hare hare wolf 2.txt wolf bear bear 3.txt bear bear bear #include <Array.au3> Local $aArray[4][4] Local $iRows = UBound($aArray, 1) Local $iCols = UBound($aArray, 2) Local $iDimension = UBound($aArray, 0) For $i = 0 To $iRows - 1 For $j = 0 To $iCols - 1 $t = FileReadLine(''&$j&'.txt', $i) $aArray[$i][$j] = $t Next Next _ArrayDisplay($aArray, 'table')
spudw2k Posted January 17, 2020 Posted January 17, 2020 _ArrayFindAll should help 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
Rei10 Posted January 17, 2020 Author Posted January 17, 2020 (edited) Local $aResult = _ArrayFindAll($aArray, "bear") _ArrayDisplay($aResult, "Found") MsgBox($MB_SYSTEMMODAL, "Found", "Column" & $aResult) doesn't show anything For $i = 0 To $iRows - 1 For $j = 0 To $iCols - 1 $t= $aArray[$i][$j] If $t=='bear' Then FileWrite('10.txt', '1') Next Next $r=FileReadLine('10.txt', 1) $rt=StringLen($r) MsgBox($MB_SYSTEMMODAL,'bear', $rt) So it sums up if there is a cell value. Edited January 17, 2020 by Rei10
Nine Posted January 17, 2020 Posted January 17, 2020 Something like this : #include <Array.au3> Const $NUMBER_OF_FILES = 3 Local $aArray[0] For $i = 1 to $NUMBER_OF_FILES _ArrayAdd ($aArray, FileRead ($i & ".txt"), 0, @CRLF) Next _ArraySort ($aArray) _ArrayDisplay ($aArray) Local $aFinal [ubound($aArray)][2], $sValue, $iFinal = -1 For $i = 0 to UBound($aArray)-1 If $aArray[$i] = "" Then ContinueLoop If $aArray[$i] = $sValue Then $aFinal[$iFinal][1] += 1 Else $iFinal += 1 $sValue = $aArray[$i] $aFinal[$iFinal][0] = $sValue $aFinal[$iFinal][1] = 1 EndIf Next ReDim $aFinal[$iFinal+1][2] _ArrayDisplay ($aFinal) Rei10 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
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