How do I avoid out of Memory Errors when parsing a big text file

Photomofo

Active Member
Joined
Aug 20, 2012
Messages
259
I'm working on a program that parses a text file into a useful layout.

Here's the program.

https://drive.google.com/open?id=0B5_Yx6GF6MxqUWR0VmRlOXMxdWs

Here's the text file.

[TABLE="width: 978"]
<tbody>[TR]
[TD="class: xl65, width: 978"]http://api.eia.gov/bulk/EBA.zip[/TD]
[/TR]
</tbody>[/TABLE]

Here's the section of code that hangs up. If I hard code in the location of File_x the code will run. If I used the GetOpenFilename function the code hangs up. Another problem is that I can only run the program once because it uses up all the memory. Is there a way to purge the EBA_File after I've broken it up into smaller strings?


'***************************************************************


Code:
'Get EBA File
'***************************************************************
MsgBox "GET EBA"
File_x = Application.GetOpenFilename()


'File_x = "C:\EBA.txt"


Set objFS = CreateObject("Scripting.FileSystemObject")
Set objFile = objFS.GetFile(File_x)
Set objTS = objFile.OpenAsTextStream(ForReading, TristateFalse)
EBA_File = objTS.Read(objFile.Size)
'***************************************************************


'Chop up EBA_File into Smaller Overlapping Strings
'***************************************************************
k = Application.RoundUp(Len(EBA_File) / 50000000, 0)


For i = 1 To k


String_Index(i) = Mid(EBA_File, (i - 1) * 50000000 + 1, 51000000)


Next i
'***************************************************************
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Is there a way to purge the EBA_File after I've broken it up into smaller strings?
Code:
EBA_File = vbnullstring
 
Upvote 0
Thank you... I incorporated your suggestion along with erasing all the other arrays that are used in the script. Unfortunately I still get the out of memory error when I try to run the program a second time.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,323
Members
452,635
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top