J
jamiedora
Hello,
I wanted to ask if there was a method for recusevly applying the split
function to a single array. Currently, I place all values into the
array 'Lines' then plug these values into the array 'Lines1' (this loop
is denoted by '**********).
Because I would like to optimize this procedure (this is a very large
text file, so I had to break the string into chunks due to memory
issues), can I recursivly add elements to the array 'Lines' without
having to create a new array 'Lines1'?
Thanks,
'-- Code --
FN = FreeFile
Index1 = 0
Index0 = 0
VarChunkPos = 1
Open FileName For Binary As FN
VarChunk = 100000
ChunkLimit = LOF(FN)
TotalFile = Space(VarChunk)
VarChunkPos = 1
Index0 = 0
Do
TotalFile = Space(VarChunk)
Get #FN, VarChunkPos, TotalFile 'Read entire file into the TotalFile
string variable
Lines = Split(TotalFile, vbLf) 'Split the file using the Line Feed
character as delimiter
ReDim Preserve Lines(UBound(Lines))
TotalFile = ""
Index0 = -1 'Reset counter
Do '**********
Index0 = Index0 + 1
Index1 = Index1 + 1
If Index0 = 0 And Index1 <> 1 Then
Lines1(Index1 - 1) = Lines1(Index1 - 1) & Lines(Index0)
Else
ReDim Preserve Lines1(Index1)
Lines1(Index1) = Lines(Index0)
End If
Loop Until Index0 = UBound(Lines) '**********
If VarChunkPos > ChunkLimit Then
Exit Do
End If
VarChunkPos = VarChunk + VarChunkPos
Loop
I wanted to ask if there was a method for recusevly applying the split
function to a single array. Currently, I place all values into the
array 'Lines' then plug these values into the array 'Lines1' (this loop
is denoted by '**********).
Because I would like to optimize this procedure (this is a very large
text file, so I had to break the string into chunks due to memory
issues), can I recursivly add elements to the array 'Lines' without
having to create a new array 'Lines1'?
Thanks,
'-- Code --
FN = FreeFile
Index1 = 0
Index0 = 0
VarChunkPos = 1
Open FileName For Binary As FN
VarChunk = 100000
ChunkLimit = LOF(FN)
TotalFile = Space(VarChunk)
VarChunkPos = 1
Index0 = 0
Do
TotalFile = Space(VarChunk)
Get #FN, VarChunkPos, TotalFile 'Read entire file into the TotalFile
string variable
Lines = Split(TotalFile, vbLf) 'Split the file using the Line Feed
character as delimiter
ReDim Preserve Lines(UBound(Lines))
TotalFile = ""
Index0 = -1 'Reset counter
Do '**********
Index0 = Index0 + 1
Index1 = Index1 + 1
If Index0 = 0 And Index1 <> 1 Then
Lines1(Index1 - 1) = Lines1(Index1 - 1) & Lines(Index0)
Else
ReDim Preserve Lines1(Index1)
Lines1(Index1) = Lines(Index0)
End If
Loop Until Index0 = UBound(Lines) '**********
If VarChunkPos > ChunkLimit Then
Exit Do
End If
VarChunkPos = VarChunk + VarChunkPos
Loop