autoit二维数组计数数量



我想计算5列中具有相同值/数据的单位数量。我尝试使用For-Next循环。但当数据较大且为200行时,它会出现问题。以下是一些数据示例:

Row,Col 0,Col 1,Col 2,Col 3,Col 4,Col 5
[0],6/29/2015,ABC,FVT,Battery failed,Soldering Process Issue,Battery Cold Solder
[1],6/29/2015,ABC,FVT,Battery failed,Incoming Material Issue,Battery Defective
[2],6/27/2015,ABC,FVT,Battery failed,Incoming Material Issue,Battery Defective
[3],6/29/2015,DEF,FVT,Battery failed,Incoming Material Issue,Battery Defective
[4],6/29/2015,DEF,FVT,Battery failed,Incoming Material Issue,Battery Defective
[5],6/29/2015,DEF,FVT,Battery failed,Incoming Material Issue,Battery Defective
[6],6/29/2015,DEF,FVT,Battery failed,Incoming Material Issue,Battery Defective
[15],6/29/2015,DEF,FVT,Battery failed,Incoming Material Issue,Battery Low Batt <60%
[16],6/29/2015,DEF,FVT,Battery failed,Incoming Material Issue,Battery Low Batt <60%
[17],6/29/2015,DEF,FVT,Battery failed,Incoming Material Issue,Battery Low Batt <60%
[18],6/29/2015,DEF,FVT,Power_Management_IC failed,Soldering Process Issue,Battery Solder Bridge
[19],6/29/2015,ABC,FVT,BI failed,Soldering Process Issue,BI Wirebus Broken
[20],6/29/2015,ABC,FVT,BI failed,Soldering Process Issue,BI Wirebus Broken
[21],6/29/2015,ABC,FVT,BI failed,Soldering Process Issue,BI Wirebus Circuitry line Open - VSN
[22],6/29/2015,ABC,FVT,BI failed,Assembling Process Issue,BI Wirebus Damage
[23],6/29/2015,ABC,FVT,BI failed,Soldering Process Issue,BI Wirebus Damage
[24],6/26/2015,ABC,FVT,BI failed,Soldering Process Issue,BI Wirebus Damage
[25],6/29/2015,ABC,FVT,BI failed,Soldering Process Issue,BI Wirebus Short - (GND & VSP)
[26],6/29/2015,ABC,FVT,BI failed,Soldering Process Issue,BI Wirebus Short - (GND & VSP)
[27],6/29/2015,ABC,FVT,BI failed,Soldering Process Issue,BI Wirebus Short - (IOM & VSP)

想要的数据进入:

Row,Col 0,Col 1,Col 2,Col 3,Col 4,Col 5,Qty
[0],6/26/2015,ABC,FVT,BI failed,Soldering Process Issue,BI Wirebus Damage,1
[1],6/27/2015,ABC,FVT,Battery failed,Incoming Material Issue,Battery Defective,1
[2],6/29/2015,ABC,FVT,Battery failed,Incoming Material Issue,Battery Defective,1
[3],6/29/2015,ABC,FVT,Battery failed,Soldering Process Issue,Battery Cold Solder,1
[4],6/29/2015,DEF,FVT,Battery failed,Incoming Material Issue,Battery Defective,4
[5],6/29/2015,DEF,FVT,Battery failed,Incoming Material Issue,Battery Low Batt <60%,3
[6],6/29/2015,DEF,FVT,Power_Management_IC failed,Soldering Process Issue,Battery Solder Bridge,1
[7],6/29/2015,ABC,FVT,BI failed,Assembling Process Issue,BI Wirebus Damage,1
[8],6/29/2015,ABC,FVT,BI failed,Soldering Process Issue,BI Wirebus Broken,2
[9],6/29/2015,ABC,FVT,BI failed,Soldering Process Issue,BI Wirebus Circuitry line Open - VSN,1
[10],6/29/2015,ABC,FVT,BI failed,Soldering Process Issue,BI Wirebus Damage,1
[11],6/29/2015,ABC,FVT,BI failed,Soldering Process Issue,BI Wirebus Short - (GND & VSP),2
[12],6/29/2015,ABC,FVT,BI failed,Soldering Process Issue,BI Wirebus Short - (IOM & VSP),1

以下是循环autoit脚本:

_ArrayDisplay($Finding,"Finding Data")
$fSymUnique = _ArrayUnique($Finding,3)
$fModelUnique = _ArrayUnique($Finding,1)
$fAnalyUnique = _ArrayUnique($Finding,4)
$fDefectUnique = _ArrayUnique($Finding,5)
Dim $aFinding[UBound($Finding)][7]
$i = -1
For $a = 1 To UBound($fModelUnique)-1
    ;$i = $i+1
    For $b = 1 To UBound($fSymUnique)-1
        ;$i = $i+1
        For $e = 1 To UBound($fAnalyUnique)-1
            ;$i = $i+1
            For $c = 1 To UBound($fDefectUnique)-1
                $i = $i+1
                For $d = 0 To UBound($Finding)-1
                    $1 = StringCompare($fModelUnique[$a],$Finding[$d][3])
                    $2 = StringCompare($fSymUnique[$b],$Finding[$d][3])
                    $3 = StringCompare($fDefectUnique[$c],$Finding[$d][5])
                    $4 = StringCompare($Date1,$Finding[$d][0])
                    $5 = StringCompare($fAnalyUnique[$e],$Finding[$e][4])
                    ;$Sum = $1+$2+$3+$4
                    If $1 = 0 And $2 = 0 And $3 = 0 And $4 = 0 And $5 = 0 Then
                        ReDim $aFinding[$i+1][7]
                        $aFinding[$i][0] = $i
                        $aFinding[$i][4] = $Finding[$d][5]
                        $aFinding[$i][2] = $Finding[$d][2]
                        $aFinding[$i][3] = $Finding[$d][3]
                        $aFinding[$i][4] = $Finding[$d][4]
                        $aFinding[$i][5] = $Finding[$d][5]
                        $aFinding[$i][6] = $aFinding[$i][6]+1
                    EndIf
                Next
            Next
        Next
    Next
Next

这就是您想要的吗?

#include <MsgBoxConstants.au3>
#include <Array.au3>
Global $result_A[1][2]
Example()
Func Example()
    Local $lines_A = FileReadToArray(@ScriptDir & 'ArrayCount.txt')
    If @error Then
        MsgBox($MB_SYSTEMMODAL, "", "There was an error reading the file. @error: " & @error) ; An error occurred reading the current script file.
    Else
        For $i = 0 To UBound($lines_A) - 1 ; Loop through the array.
            $index = _ArraySearch($result_A, $lines_A[$i])
            If $index = -1 Then
                _ArrayAdd($result_A, $lines_A[$i] & '|1')
            Else
                $result_A[$index][1] += 1
            EndIf
        Next
    EndIf
    _ArrayDisplay($result_A)
EndFunc   ;==>Example

相关内容

  • 没有找到相关文章

最新更新