Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Trimming large files
#1
i have a file that is really large and i need to clip off the first three or four lines but it's so large that I keep getting "Insufficient system resources exist to complete the requested service." I tried looking into the File variable but can't find a way to clip the lines out.

is there a way to do this?

thanks.
An old blog on QM coding and automation.

The Macro Hook
#2
I never tried to do something similar, but would try to: Open the file with File f.Open("file" "r"), read the first several lines, then sequentially read to eg 64 KB buffers and write to another file opened eg with File f2.Open("file2" "w"). When done, delete file1 and rename file2.
#3
ReadLine seems to only pull 301 characters.
is there a reason that it isn't pulling the whole line?

it looks like the function is set to only pull so many characters (256) can that be changed without making it all unstable?
An old blog on QM coding and automation.

The Macro Hook
#4
It is a bug. Replace File.ReadLine code to
Code:
Copy      Help
function# str&line ;;Returns 1 on success, 0 on EOF.

if(!m_file) end ES_INIT
int n1 n2
if(line.nc<250) line.all(250); else line.len=0
rep
,n1=line.nc-line.len
,if(fgets(line+line.len n1 m_file))
,,n2=len(line+line.len)
,,line.fix(line.len+n2)
,,if(n2<n1-1 or line[line.len-1]=10) line.rtrim("[]"); ret 1
,,line.all(line.len+250 1)
,else if(line.len) ret 1
,else ret
#5
perfect!

thanks.
An old blog on QM coding and automation.

The Macro Hook
#6
should this new code have made it into the new 2.2 version?
An old blog on QM coding and automation.

The Macro Hook
#7
It is in QM 2.2.0.
#8
mine shows this

line.all(line.len+1000 1)
An old blog on QM coding and automation.

The Macro Hook
#9
Just changed 250 to 1000 to allocate more.


Forum Jump:


Users browsing this thread: 1 Guest(s)