I'm having some trouble debugging this issue. I use the following ParseCSV script:
AutoIt
Func _ParseCSV($sFile, $sDelimiters = ',;', $sQuote = '"', $iFormat = 0, $iAddIndex = 0, $AddHeader = 0) Local Static $aEncoding[6] = [0, 0, 32, 64, 128, 256] If $iFormat < -1 Or $iFormat > 6 Then Return SetError(3, 0, 0) ElseIf $iFormat > -1 Then Local $hFile = FileOpen($sFile, $aEncoding[$iFormat]), $sLine, $aTemp, $aCSV[1], $iReserved, $iCount If @error Then Return SetError(1, @error, 0) $sFile = FileRead($hFile) FileClose($hFile) EndIf If $sDelimiters = "" Or IsKeyword($sDelimiters) Then $sDelimiters = ',;' If $sQuote = "" Or IsKeyword($sQuote) Then $sQuote = '"' $sQuote = StringLeft($sQuote, 1) $iAddIndex = Number($iAddIndex=True) $AddHeader = Number($AddHeader=True) Local $srDelimiters = StringRegExpReplace($sDelimiters, '[\\\^\-\[\]]', '\\\0') Local $srQuote = StringRegExpReplace($sQuote, '[\\\^\-\[\]]', '\\\0') Local $sPattern = StringReplace(StringReplace('(?m)(?:^|[,])\h*(["](?:[^"]|["]{2})*["]|[^,\r\n]*)(\v+)?', ',', $srDelimiters, 0, 1), '"', $srQuote, 0, 1) Local $aREgex = StringRegExp($sFile, $sPattern, 3) If @error Then Return SetError(2, @error, 0) $sFile = '' ; save memory Local $iBound = UBound($aREgex), $iIndex = $AddHeader, $iSubBound = 1+$iAddIndex, $iSub = $iAddIndex, $sLast='' ;changed If $iBound Then $sLast = $aREgex[$iBound-1] Local $aResult[$iBound + $iAddIndex][$iSubBound] ;changed For $i = 0 To $iBound - 1 If $iSub = $iSubBound Then $iSubBound += 1 ReDim $aResult[$iBound][$iSubBound] EndIf Select Case StringLeft(StringStripWS($aREgex[$i], 1), 1) = $sQuote $aREgex[$i] = StringStripWS($aREgex[$i], 3) $aResult[$iIndex][$iSub] = $aREgex[$i] ;~ $aResult[$iIndex][$iSub] = StringReplace(StringMid($aREgex[$i], 2, StringLen($aREgex[$i])-2), $sQuote&$sQuote, $sQuote, 0, 1) Case StringRegExp($aREgex[$i], '^\v+$') ; StringLen($aREgex[$i]) < 3 And StringInStr(@CRLF, $aREgex[$i]) ;new line found StringReplace($aREgex[$i], @LF, "", 0, 1) $iIndex += @extended $iSub = $iAddIndex ;changed ContinueLoop Case Else $aResult[$iIndex][$iSub] = $aREgex[$i] EndSelect $aREgex[$i] = 0 ; save memory $iSub += 1 If $iAddIndex Then $aResult[$iIndex][0] = $iIndex ;added Next If Not StringRegExp($sLast, '^\v+$') Then $iIndex+=1 ReDim $aResult[$iIndex][$iSubBound - 1] If $iAddIndex Then $aResult[0][0] = "Index" ;added If $AddHeader Then For $i = 1 To $iSubBound - 2 $aResult[0][$i] = "Col" & $i Next EndIf Return $aResult EndFunc ;==>_ParseCSV
but on some of the files I am importing to an array using this method, the script crashes (No error in SCITE but a windows crash dialog) giving the following:
Problem signature:
Problem Event Name: APPCRASHApplication Name: autoit3.exeApplication Version: 3.3.13.19Application Timestamp: 53fa0936Fault Module Name: autoit3.exeFault Module Version: 3.3.13.19Fault Module Timestamp: 53fa0936Exception Code: c00000fdException Offset: 000102f9OS Version: 6.1.7601.2.1.0.256.48Locale ID: 1033Additional Information 1: 4181Additional Information 2: 41810812715e7a6496820cf28371c79cAdditional Information 3: 9615Additional Information 4: 9615c990bcbe602452124ea23ad11713Read our privacy statement online:If the online privacy statement is not available, please read our privacy statement offline:C:\Windows\system32\en-US\erofflps.txt
I have tried deleting some of the rows in the CSV file and sometimes it works, other times it doesn't. I think the issue might be with the amount of memory I have because if I keep it to 100 records (out of 1600) it never crashes. One of the records is a very long text field that may also be causing the issue. Any suggestions on how to figure out what the issue is here so I can actually handle the exception?