Jump to content

Is there a character limit on a fileread or an array in a for statement?


gte
 Share

Recommended Posts

I have a file read command, where it reads a file with the following values (3100+ lines) but stops around line 700 and returns the rest as 0's ? The code basically outputs a numerical value each line, saves it as a text file, then replaces the @crlf with a + and adds all of the values together

Am I at a character limitation? If so, how do I get around that?

for $i = 1 To $FileList[0] Step 1

    Next
    $sString = "Document docsrc="
    $aFileList = _FileListToArray("c:\temp\testxmls", "*.xml", 1) 


For $i = 1 To $aFileList[0]
    $iCount = UBound (StringRegExp(FileRead("c:\temp\testxmls\" & $aFileList[$i]), "(?i)(" & $sString & ")", 3))  
    FileWrite("c:\temp\testxmls\results.txt", $iCount & @CRLF)              
    ConsoleWrite($i & " - " & $iCount & @CRLF)
Next

fileread = FileRead("c:\temp\testxmls\results.txt") 
$out = StringReplace($fileread, @CRLF, "+")
$sum = Execute($out)

64
64
64
64
64
64
64
64
64
64
18
39
2
32
64
64
64
64
64
64
64
64
64
21
1
1
64
64
64
64
64
64
59
64
64
47
4
21
44
3
64
64
64
64
64
64
64
64
64
32
2
26
64
64
64
64
64
64
64
64
64
64
64
64
64
37
1
64
4
1
64
64
64
64
64
64
64
64
64
64
59
24
47
19
2
2
21
28
64
64
64
64
64
64
64
64
64
30
54
1
3
64
64
64
64
64
64
64
64
64
64
64
64
64
64
64
64
64
64
64
64
60
27
4
2
56
1
7
53
64
39
64
64
64
64
64
58
14
26
64
64
64
64
64
64
64
64
64
64
64
64
64
64
36
19
12
34
2
30
64
64
64
64
64
64
64
64
16
64
24
4
10
36
64
64
64
64
64
64
64
64
64
64
64
64
64
64
21
11
3
64
64
27
62
49
1
64
64
64
64
64
64
64
64
64
64
64
64
64
64
64
64
24
4
1
37
52
3
1
64
64
64
64
64
64
64
64
64
64
64
64
64
5
1
64
64
64
10
64
64
64
64
64
64
64
64
64
64
64
64
64
64
64
64
64
64
57
64
60
3
1
64
64
64
64
64
64
64
64
64
11
3
49
64
38
44
28
59
21
64
64
64
64
64
64
64
64
64
64
64
64
49
64
64
64
64
64
64
64
64
64
64
49
64
12
49
1
64
64
36
62
8
43
12
1
1
23
36
64
64
64
64
64
64
64
64
64
64
64
64
13
4
37
64
64
64
64
64
64
64
64
64
64
64
64
64
23
5
5
17
15
64
64
64
64
64
64
64
64
64
64
1
58
46
2
35
9
64
64
64
64
64
64
64
64
57
21
64
9
64
64
64
64
64
64
64
64
28
2
43
33
2
64
59
30
64
11
28
23
32
28
2
2
64
3
35
64
64
64
64
64
64
64
64
64
64
64
64
64
42
25
64
18
18
2
1
64
64
64
64
64
64
60
60
64
50
1
38
2
64
64
64
64
64
64
64
64
41
28
44
27
12
11
9
64
64
64
64
64
64
64
64
64
64
64
64
64
29
13
64
64
64
64
64
64
64
64
64
64
64
23
39
11
6
1
64
64
64
64
64
64
64
64
64
64
64
12
1
4
1
64
64
64
64
64
64
46
1
63
64
64
37
24
47
1
64
64
64
64
64
64
64
64
57
41
34
10
28
64
64
64
64
64
64
64
64
64
64
64
64
64
64
33
2
58
3
2
1
1
1
60
60
60
40
60
60
60
10
17
60
20
60
2
60
60
60
13
48
60
60
27
40
60
60
60
38
42
60
60
20
60
60
28
60
2
36
44
60
56
60
1
60
40
51
60
60
1
38
60
52
23
35
52
60
37
60
9
60
60
25
60
8
60
60
60
15
60
60
36
60
60
28
60
60
60
51
19
23
49
60
22
60
19
60
45
60
16
60
60
11
49
60
12
60
31
28
53
55
60
27
60
14
55
8
60
60
3
60
60
23
60
60
2
60
44
60
60
31
51
30
23
60
54
60
14
60
60
29
60
60
60
60
60
60
60
31
13
60
37
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
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0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
Link to comment
Share on other sites

You have to pass a valid script line to Execute(). That script line is limited to 4K characters. You are passing it a long string like "64+64+18+39+2+..." which is a valid expression, but probably comes up longer than 4K characters.

Read your file in blocks of 100 lines at a time, say, and sum up the values along the way with a loop.

:)

Edit: Added detail.

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Thanks Psalty, I will try that, for loops are my achilles, but I'm getting better at them, haha!

You have to pass a valid script line to Execute(). That script line is limited to 4K characters. You are passing it a long string like "64+64+18+39+2+..." which is a valid expression, but probably comes up longer than 4K characters.

Read your file in blocks of 100 lines at a time, say, and sum up the values along the way with a loop.

:)

Edit: Added detail.

Link to comment
Share on other sites

Psalty, I'm not sure sure it's failing at the long string, because my "c:\temp\testxmls\results.xml is showing 0's (as displayed in the code portion) so it seems like it might be failing in this part of the code?

I think it's failing at the variable $iCount?

Is there a way to declare this variable so that it can hold more than 4k characters?

For $i = 1 To $aFileList[0]
                                                    
    $iCount = UBound (StringRegExp(FileRead("c:\temp\testxmls\" & $aFileList[$i]), "(?i)(" & $sString & ")", 3))
    FileWrite("c:\temp\testxmls\results.txt", $iCount & @CRLF)              
    ConsoleWrite($i & " - " & $iCount & @CRLF)
                            
Next

You have to pass a valid script line to Execute(). That script line is limited to 4K characters. You are passing it a long string like "64+64+18+39+2+..." which is a valid expression, but probably comes up longer than 4K characters.

Read your file in blocks of 100 lines at a time, say, and sum up the values along the way with a loop.

:)

Edit: Added detail.

Link to comment
Share on other sites

Maybe something like this?

For $i = 1 To $aFileList[0] Step 1
        For $j = $i To $i[250]
        $iCount = UBound (StringRegExp(FileRead("c:\temp\testxmls\" & $aFileList[$i]), "(?i)(" & $sString & ")", 3))    
        FileWrite("c:\temp\testxmls\results.txt", $iCount & @CRLF)
        ConsoleWrite($i & " - " & $iCount & @CRLF) ; writes the console below
        
        Next                
    Next
Link to comment
Share on other sites

What do those ConsoleWrite() lines show for $iCount values? If it's not right there, nothing after that can work either. Could be your FileRead() is not getting the right path, or your StringRegExp() is not matching correctly. You could break up the nested function so debugging would be easier:

For $i = 1 To $aFileList[0]
    $sData = FileRead("c:\temp\testxmls\" & $aFileList[$i])
    $avRegExp = StringRegExp($sData, "(?i)(" & $sString & ")", 3)
    If @error Then
        ConsoleWrite("RegExp failed; $aFileList[" & $i & "] = " & $aFileList[$i] & @LF)
    Else
        $iCount = UBound($avRegExp)
        FileWrite("c:\temp\testxmls\results.txt", $iCount & @CRLF)
        ConsoleWrite($i & " - " & $iCount & @CRLF)
    EndIf
Next

As for variable sizes, an AutoIt string can theoretically be 2GB (32-bit OS, maybe larger with 64-bit). The limit is not this size of the variable, but the size of the expression input to Execute().

But why save the numbers in a string variable (or a file) at all? Why not just keep a single global variable and add up the numbers on the fly without writing them to a file?

Global $iTotalCount = 0

For $i = 1 To $aFileList[0]
    $sData = FileRead("c:\temp\testxmls\" & $aFileList[$i])
    $avRegExp = StringRegExp($sData, "(?i)(" & $sString & ")", 3)
    If @error Then
        ConsoleWrite("RegExp failed; $aFileList[" & $i & "] = " & $aFileList[$i] & @LF)
    Else
        $iTotalCount += UBound($avRegExp)
    EndIf
Next
ConsoleWrite("$iTotalCount = " & $iTotalCount & @LF)

:)

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

I wanted it logged to a file as well, which is why I have the filewrite

Here is what the console said

Posted Image

Also, the console gave this error message from xml 690 to 3128? Any idea what would cause that? Could it be that the $sData variable size is too large?

RegExp failed; $aFileList[690] = xmlfile_u000.xml

RegExp failed; $aFileList[3128] =xmlfile2_u000.xml

Using the following code

For $i = 1 To $aFileList[0] Step 1
                    ConsoleWrite("Reading $sdata")
                    $sData = FileRead("\\sd6aa7c\c$\temp\testxmls\" & $aFileList[$i])
                    $avRegExp = StringRegExp($sData, "(?i)(" & $sString & ")", 3)
                    If @error Then
                        ConsoleWrite("RegExp failed; $aFileList[" & $i & "] = " & $aFileList[$i] & @LF)
                    Else
                        $iCount = UBound($avRegExp)
                        FileWrite("\\xxxxxxx\c$\temp\testxmls\results.txt", $iCount & @CRLF)
                        ConsoleWrite($i & " - " & $iCount & @CRLF)
                    EndIf
                Next

What do those ConsoleWrite() lines show for $iCount values? If it's not right there, nothing after that can work either. Could be your FileRead() is not getting the right path, or your StringRegExp() is not matching correctly. You could break up the nested function so debugging would be easier:

For $i = 1 To $aFileList[0]
    $sData = FileRead("c:\temp\testxmls\" & $aFileList[$i])
    $avRegExp = StringRegExp($sData, "(?i)(" & $sString & ")", 3)
    If @error Then
        ConsoleWrite("RegExp failed; $aFileList[" & $i & "] = " & $aFileList[$i] & @LF)
    Else
        $iCount = UBound($avRegExp)
        FileWrite("c:\temp\testxmls\results.txt", $iCount & @CRLF)
        ConsoleWrite($i & " - " & $iCount & @CRLF)
    EndIf
Next

As for variable sizes, an AutoIt string can theoretically be 2GB (32-bit OS, maybe larger with 64-bit). The limit is not this size of the variable, but the size of the expression input to Execute().

But why save the numbers in a string variable (or a file) at all? Why not just keep a single global variable and add up the numbers on the fly without writing them to a file?

Global $iTotalCount = 0

For $i = 1 To $aFileList[0]
    $sData = FileRead("c:\temp\testxmls\" & $aFileList[$i])
    $avRegExp = StringRegExp($sData, "(?i)(" & $sString & ")", 3)
    If @error Then
        ConsoleWrite("RegExp failed; $aFileList[" & $i & "] = " & $aFileList[$i] & @LF)
    Else
        $iTotalCount += UBound($avRegExp)
    EndIf
Next
ConsoleWrite("$iTotalCount = " & $iTotalCount & @LF)

:)

Edited by gte
Link to comment
Share on other sites

As an FYI, it's starting to fail at the same line each time by the way

I've added

ConsoleWrite("Reading $sdata") right under For $i = 1 To $aFileList[0] Step 1

and it failed saying reading $sData RegExp failed $sData[690] xmlfile_u000.xml

and went on to $sData[3128]

_ArrayDisplay($aFileList[$i])

right under the line

RegExp failed; $aFileList[690] = xmlfile_u000.xml

$sData = FileRead("\\xxxxxxx\c$\temp\testxmls\" & $aFileList[$i])

and I'm seeing how many lines it writes to the console, it's taking a long time to use the console as I'm on XP and my AIT is installed on my machine, but it's reading from across the network.

It was able to get file names like this

z3247403125781.xml

BRTAZ2DAC42DS040091109AAZ.XML

but it fails on file names like this. It's either the amount of data being loaded into the array, or the file name? Any ideas?

BZde_54867_571563_u000.xml

Edited by gte
Link to comment
Share on other sites

Well, nobody is going to reproduce your environment of over 3,000 xml files just to test this. You'll have to figure it out:

1. $sData only contains the data from one file at a time. So it's size is only an issue if the xml files are HUGE (as in hundreds of MB).

2. When StringRegExp() fails, it returns an @error. Save it and add it to your console display:

$avRegExp = StringRegExp($sData, "(?i)(" & $sString & ")", 3)
    $iErrSav = @error
    If $iErrSav Then
        ConsoleWrite("RegExp failed at $aFileList[" & $i & "] = " & $aFileList[$i] & "; @error = " & $iErrSav & @LF)
    Else
        $iTotalCount += UBound($avRegExp)
    EndIf

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Yes I know no one will setup 3000+ xmls for this, nor would I expect them to. I'm just looking for guidance, so thank you for that. The XML's are not hundreds of MB each, so at least I can rule out that.

I'm still trying to figure out how to nest/limit a for statement, and then have it come back for the next round, as you recommended above. How does my code below look for doing that?

Thanks for all of the help! ;)

for $i = 1 to $aFileList [0] Step 1
      for $j = $i to $aFileList [100] Step 1
      $iCount = UBound (StringRegExp(FileRead("c:\temp\testxmls\" & $aFileList[$i]), "(?i)(" & $sString & ")", 3))
      FileWrite("c:\temp\testxmls\results.txt", $iCount & @CRLF)
      $fileread = FileRead("\\sd6aa7c\c$\temp\testxmls\results.txt")
      $out = StringReplace($fileread, @CRLF, "+") 
      If StringRight($out,1) = "+" Then
            $out = StringLeft($out,StringInStr($out,"+",0,-1)-1)
      EndIf
      $sum = Execute($out)
      Next
Next

Well, nobody is going to reproduce your environment of over 3,000 xml files just to test this. You'll have to figure it out:

1. $sData only contains the data from one file at a time. So it's size is only an issue if the xml files are HUGE (as in hundreds of MB).

2. When StringRegExp() fails, it returns an @error. Save it and add it to your console display:

$avRegExp = StringRegExp($sData, "(?i)(" & $sString & ")", 3)
    $iErrSav = @error
    If $iErrSav Then
        ConsoleWrite("RegExp failed at $aFileList[" & $i & "] = " & $aFileList[$i] & "; @error = " & $iErrSav & @LF)
    Else
        $iTotalCount += UBound($avRegExp)
    EndIf

:)

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...