Jump to content

Very long single line of text in File


Recommended Posts

I am trying to read a text file and do a string replace on each of the lines.

One of the lines in the file is very long (60000 characters)

#Include <File.au3>
#Include <Array.au3>
#include <Misc.au3>

lOCAL $aRetArray
    _FileReadToArray("test.xml", $aRetArray)
    For $i = 1 To $aRetArray[0]
        If StringInStr($aRetArray[$i], 'System.Collections.Generic.List`1[System.Single]') Then
            ConsoleWrite($aRetArray[$i] &@CRLF)
            $aRetArray[$i] = StringReplace($aRetArray[$i], "System.Collections.Generic.List`1[System.String]", "")
            ConsoleWrite($aRetArray[$i] &@CRLF)
       EndIf
    Next
    _FileWriteFromArray("test.xml", $aRetArray, 1)

@errno after the string replace gives 0.

As written the file ends up unchanged. 

StringInStr correctly identifies the line with the text in it but StringReplace doesn't do the replace. 

Probaly  missing something obvious?

Test.xml

Link to post
Share on other sites

I ran it with this and it worked fine.

#Include <File.au3>
#Include <Array.au3>
#include <Misc.au3>


Local $aRetArray

_FileReadToArray("Test.xml", $aRetArray)
For $i = 1 To $aRetArray[0]
    If StringInStr($aRetArray[$i], 'System.Collections.Generic.List`1[System.Single]') Then
        ConsoleWrite($aRetArray[$i] &@CRLF)
        $aRetArray[$i] = StringReplace($aRetArray[$i], 'System.Collections.Generic.List`1[System.Single]', "")
        ConsoleWrite($aRetArray[$i] &@CRLF)
   EndIf
Next

_FileWriteFromArray("Test.new.xml", $aRetArray, 1)

 

Edited by TheXman
Link to post
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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...