For sure, the GuiCtrlSetData is slowing your loop to a crawl!
Here is 1 way to sum one of the CSV columns for each retailer using a dictionary object to store and lookup the sums. This took between 90-160 seconds on my humble laptop to process my test file with 5 million lines. You'll most likely need to adjust the columns for your data, but hopefully this gets you going in the right direction. If you want to do something different with your data, let us know and we'll see what we can come up with.
#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>
#include <Array.au3>
Example()
Func Example()
Local $timer = TimerInit()
; Create a constant variable in Local scope of the filepath that will be read/written to.
Local Const $sFilePath = "testFile.csv"
;~ Local $sStr = "", $j = 1
;~ For $j = 1 To 5
;~ For $i = 0 To 1000000
;~ $sStr &= "wholesaler" & $j & ",retailer" & $j & ",cat1,model1,saledate,transdate," & $j & @CRLF
;~ Next
;~ Next
;~ ; Create a temporary file to read data from.
;~ If Not FileWrite($sFilePath, $sStr) Then
;~ MsgBox($MB_SYSTEMMODAL, "", "An error occurred whilst writing the temporary file.")
;~ Return False
;~ EndIf
;~ ConsoleWrite(TimerDiff($timer) & @CRLF)
;~ $timer = TimerInit()
; Open the file for reading and store the handle to a variable.
Local $hFileOpen = FileOpen($sFilePath, $FO_READ)
If $hFileOpen = -1 Then
MsgBox($MB_SYSTEMMODAL, "", "An error occurred when reading the file.")
Return False
EndIf
;create dictionary object to hold the sums
Local $oRetailerSums = ObjCreate("Scripting.Dictionary")
Local $sFileLine, $aLineParts, $i = 0
; loop through the file lines
While 1
;read the next line
$sFileLine = FileReadLine($hFileOpen)
If @error Then ExitLoop
;process this line
$aLineParts = StringSplit($sFileLine, ",")
If @error Then ContinueLoop
;add this value to the matching retailer sum
$oRetailerSums.Item($aLineParts[2]) = $oRetailerSums.Item($aLineParts[2]) + $aLineParts[7]
;display line after every 100,000 lines to indicate progress
$i += 1
If Mod($i, 100000) = 0 Then
ConsoleWrite("Line " & $i & " " & $sFileLine & @CRLF)
EndIf
WEnd
ConsoleWrite(TimerDiff($timer) & @CRLF)
; Close the handle returned by FileOpen.
FileClose($hFileOpen)
;Create array of retailer/value pairs for display
Local $aRetailersFound = $oRetailerSums.Keys()
Local $aRetailerSums[UBound($aRetailersFound)][2]
For $i = 0 To UBound($aRetailersFound) - 1
$aRetailerSums[$i][0] = $aRetailersFound[$i]
$aRetailerSums[$i][1] = $oRetailerSums.Item($aRetailersFound[$i])
Next
_ArrayDisplay($aRetailerSums)
EndFunc ;==>Example