Jeff Massung wrote:
I'm still new to Rev, but in other languages this is dead simple:
...
// nuke everything else at the end of the file
trunctate(fp, new_len);
...
Done.
Now, maybe this isn't as easy in Rev as it is in C and *many* other
languages. But it should be [if it
Richard Gaskin wrote:
That looks similar to what I posted here on the 9th:
open file tFile for update
seek relative -1000 in file tFile
repeat
read from file tFile until cr
if it is not empty then
put it after tBuffer
else
delete last line of tBuffer
Jim Bufalini wrote:
Just one thing Alex, you need to:
put URLDecode(the detailed files) into t
in case the file name has, for example, a space in it.
Thanks Jum, I didn't spot that.
But then, if the file name had a comma in it, I'd be caught out. I think
what I needed was to
Alex Tweedly wrote:
Richard Gaskin wrote:
That looks similar to what I posted here on the 9th:
open file tFile for update
seek relative -1000 in file tFile
repeat
read from file tFile until cr
if it is not empty then
put it after tBuffer
else
Richard Gaskin wrote:
But FWIW, I tried your version and it seemed to leave the file
unchanged
If your original file ends in a cr then Alex's code would end in absolutely
no change. ;-)
Aloha from Hawaii,
Jim Bufalini
___
use-revolution mailing
Jim Bufalini wrote:
Richard Gaskin wrote:
But FWIW, I tried your version and it seemed to leave the file
unchanged
If your original file ends in a cr then Alex's code would end in absolutely
no change. ;-)
Thanks, Jim. I tried it both ways; no change to the file's contents,
although the
Jim Bufalini wrote:
Richard Gaskin wrote:
But FWIW, I tried your version and it seemed to leave the file
unchanged
If your original file ends in a cr then Alex's code would end in absolutely
no change. ;-)
That's not what my testing showed (or appeared to show). Here's the
short
Richard Gaskin wrote:
Jim Bufalini wrote:
Richard Gaskin wrote:
But FWIW, I tried your version and it seemed to leave the file
unchanged
If your original file ends in a cr then Alex's code would end in
absolutely
no change. ;-)
Thanks, Jim. I tried it both ways; no change to the
Alex Tweedly wrote:
I suspect the *trick* of opening a file for append, then seeking back
into the middle of the file before doing a write is OS-dependent. It's
certainly not documented (either way), and I was surprised when Jim
said
that it could be done.
Intuitively, 'append' should mean
Alex Tweedly wrote:
I strongly suspect it only works on Windows :-( Sorry.
I don't have either a Mac or Linux box to try it on, however I did just
try it on the on-rev server (as an .irev script) and it also appears to
leave the file unchanged there.
I wonder if it has to do with the
J. Landman Gay wrote:
Alex Tweedly wrote:
I strongly suspect it only works on Windows :-( Sorry.
I don't have either a Mac or Linux box to try it on, however I did
just try it on the on-rev server (as an .irev script) and it also
appears to leave the file unchanged there.
I wonder if it
On Sat, Feb 13, 2010 at 8:25 AM, Alex Tweedly a...@tweedly.net wrote:
Could you try this in your multi-line msg box and let me know what it does
on Mac ?
put abcdefg CR into URL file:b.txt
put URL file:b.txt
open file b.txt for append
write x to file b.txt at 2
close file b.txt
put URL
Kay C Lan wrote:
On Sat, Feb 13, 2010 at 8:25 AM, Alex Tweedly a...@tweedly.net wrote:
Could you try this in your multi-line msg box and let me know what it does
on Mac ?
put abcdefg CR into URL file:b.txt
put URL file:b.txt
open file b.txt for append
write x to file b.txt at 2
close file
Kay C Lan wrote:
On Sat, Feb 13, 2010 at 8:25 AM, Alex Tweedly a...@tweedly.net wrote:
Could you try this in your multi-line msg box and let me know what it does
on Mac ?
put abcdefg CR into URL file:b.txt
put URL file:b.txt
open file b.txt for append
write x to file b.txt at 2
close file
Jeff Massung wrote:
Warren,
I've read through most of these suggestions, but I'm surprised that the
obvious hasn't been suggested yet (that I've seen): skip everything...
Hasn't been suggested because it won't work.
put the length of url file:myfile.txt into tEnd
open file myfile.txt for
Alex Tweedly wrote:
Jeff Massung wrote:
Warren,
I've read through most of these suggestions, but I'm surprised that
the
obvious hasn't been suggested yet (that I've seen): skip
everything...
Hasn't been suggested because it won't work.
put the length of url file:myfile.txt
On Thu, Feb 11, 2010 at 5:49 PM, Alex Tweedly a...@tweedly.net wrote:
Jeff Massung wrote:
Warren,
I've read through most of these suggestions, but I'm surprised that the
obvious hasn't been suggested yet (that I've seen): skip everything...
Hasn't been suggested because it won't work.
Jeff Massung wrote:
I'm still new to Rev, but in other languages this is dead simple:
void truncate_huge_file(const char* filename)
{
FILE* fp = fopen(filename,wb);
char bytes[200];
size_t new_len;
// move to the end of the file, read 200 bytes
fseek(fp, -200, SEEK_END);
Thanks for all the suggestions. I will look into trying some of them
to see what works best for me. The file currently contains
105,750,304 records.
I will report back my findings.
Thanks,
Warren
On Tue, Feb 9, 2010 at 11:58 PM, J. Landman Gay
jac...@hyperactivesw.com wrote:
Jim Bufalini
You mean you'll report back when you only have 105,750,303 records ;-)
On Wed, Feb 10, 2010 at 9:06 PM, Warren Kuhl warrenk...@gmail.com wrote:
Thanks for all the suggestions. I will look into trying some of them
to see what works best for me. The file currently contains
105,750,304
Warren,
I've read through most of these suggestions, but I'm surprised that the
obvious hasn't been suggested yet (that I've seen): skip everything...
put the length of url file:myfile.txt into tEnd
open file myfile.txt for text update
seek to tEnd in file myfile.txt
From here just back up a
Jeff,
This line:
put the length of url file:myfile.txt into tEnd
Loads the entire file into memory in order to get its length.
- Brian
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe
On Feb 10, 2010, at 11:26 PM, Brian Yennie wrote:
Jeff,
This line:
put the length of url file:myfile.txt into tEnd
Loads the entire file into memory in order to get its length.
That's a joke, right? :-(
A freakin' OS call could get that just by touching an I-Node. Please, God,
It's more a product of the syntax than anything. url file:myfile.txt is a
container, and the length operates on it as such. URL containers are pretty
darn handy in general, but this is one potential gotcha.
You can use the detailed files to get information about a file, including its
size in
I have a large text file (100,000,000+ records). I need to write a
utility that removes the last record of the file. Is there anyway to
just remove the last record without reading through the complete file
with RunRev?
Thanks,
Warren
___
doesn't that work?:
delete line -1 of file myTextFile
Till
Am 09.02.2010 um 14:52 schrieb Warren Kuhl:
I have a large text file (100,000,000+ records). I need to write a
utility that removes the last record of the file. Is there anyway to
just remove the last record without reading through
Warren,
I have a large text file (100,000,000+ records). I need to write a
utility that removes the last record of the file. Is there anyway to
just remove the last record without reading through the complete file
with RunRev?
This is totally untested but logically you could:
1. First
Jim,
I will give this a try. I was trying to go down the same path by
getting the number of records of the file...then trying to determine
if I could just read the last line and removing the EOF. Is there
anyway to specifiy a READ to a certain line of a file without reading
through the whole
Warren,
I will give this a try. I was trying to go down the same path by
getting the number of records of the file...then trying to determine
if I could just read the last line and removing the EOF. Is there
anyway to specifiy a READ to a certain line of a file without reading
through the
Jim,
Thanks for the explanationI will give this a try.
Thanks!
Warren
On Tue, Feb 9, 2010 at 9:08 AM, Jim Bufalini j...@visitrieve.com wrote:
Warren,
I will give this a try. I was trying to go down the same path by
getting the number of records of the file...then trying to determine
I don't think this will work, Jim. If you open a file for write, then
it erases the entire content of the file first
as the docs say (emphasis added)...
The file to write to must be opened first with the open file command,
and the mode the file was opened in must be write, append, or update.
Piggy-backing here:
I have a large text file (100,000,000+ records). I need to write a
utility that removes the last record of the file. Is there anyway to
just remove the last record without reading through the complete file
with RunRev?
It sounds like a big file, but Rev is pretty good
Would the seek command help?
Presumably it would move the file pointer to the specified point without
having to load the entire file into RAM.
If you knew your lines were shorter than a given length, say 1000 chars,
you could so something like:
open file tFile for append
seek relative
See why you shouldn't trust off-the-cuff code?
Where I wrote:
open file tFile for append
...I meant to write:
open file tFile for update
--
Richard Gaskin
Fourth World
Rev training and consulting: http://www.fourthworld.com
Webzine for Rev developers: http://www.revjournal.com
Alex,
It does work, just not exactly how I said to do it. ;-) You have to open
the file for append*, instead of *write* and then write at a byte offset.
So:
open file filename for append
write This is the EOF to file fileName at
close file filename
I just tested on an approximately 10kb
Jacque wrote:
Worth a test anyway. I've used it on files that were several megs in
size without a problem, but they weren't super huge, just kinda big.
Hi Jacque, I made the suggestion I did because at 100 Million records plus,
that's an awfully big read into memory just to delete the last
...@lists.runrev.com [mailto:use-revolution-
boun...@lists.runrev.com] On Behalf Of Richard Gaskin
Sent: Tuesday, February 09, 2010 2:10 PM
To: How to use Revolution
Subject: Re: Reading/Deleting Last Line Of File
See why you shouldn't trust off-the-cuff code?
Where I wrote:
open file
Jim Bufalini wrote:
Jacque wrote:
Worth a test anyway. I've used it on files that were several megs in
size without a problem, but they weren't super huge, just kinda big.
Hi Jacque, I made the suggestion I did because at 100 Million records plus
100 million? Yes, well...I think I read the
38 matches
Mail list logo