Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Speed and Memory Management in REBOL Re:(2)

From: jelinem1:nationwide at: 6-Sep-2000 9:40

--0__=85256952004AC78E8f9e8a93df938690918c85256952004AC78E Content-type: text/plain; charset=us-ascii I always thought it was more "efficient" to read in and write a block of data at a time (or the whole file) as opposed to a line of some arbitrary length. I guess it depends on the OS treatment of buffering data from the device when reading in line-by-line. IMO If you are worried about memory efficiency, program in C. Interpreted languages are inefficient by design, however much I prefer them (esp REBOL). [bo--rebol--com] on 09/05/2000 05:37:39 PM From: [bo--rebol--com] on 09/05/2000 05:37 PM Please respond to [list--rebol--com] To: [list--rebol--com] cc: Subject: [REBOL] Speed and Memory Management in REBOL Re: princepawn, Attached you will find an example that should allow CSV conversion of a file of any length. Shocked and honored that simple old %convert-csv.r is one of the most popular scripts! Have fun! -Bo On 5-Sep-2000/12:52:36-7:00, [princepawn--lycos--com] wrote:
>I was glancing at one of the most popular scripts at the REBOL archive and
developed some questions:
>1- Is it possible to incrementally write to a file in REBOL? >2- Is it possible to append to a file in REBOL >3- This script seems in-efficient and memory wasteful: it reads and entire
file into a temporary array and then converts the array. In Perl, I could do each conversion as I read in each line and write each line out after each conversion.
>REBOL [ > Title: "Comma-Seperated-Values to REBOL converter" > Date: 16-Jun-1999 > Author: "Bohdan Lechnowsky" > Email: [bo--rebol--com] > File: %convert-csv.r > Purpose: <lb> > Convert CSV files to REBOL blocks > <rb> > Category: [file util db text 2] >] > >csv: read/lines to-file ask "Filename to convert from CSV: " > >block: make block! 100 > >headings: parse/all first csv "," > >foreach line next csv [append block parse/all line ","] > >save to-file ask "Filename to save to: " head insert/only block headings > >Get your FREE Email and Voicemail at Lycos Communications at >http://comm.lycos.com >
-- Bohdan "Bo" Lechnowsky REBOL Adventure Guide REBOL Technologies 707-467-8000 (http://www.rebol.com) Download the REBOL Messaging Language The Official Source for REBOL Books (http://www.REBOLpress.com) (See attached file: new-csv.r) --0__=85256952004AC78E8f9e8a93df938690918c85256952004AC78E Content-type: application/octet-stream; name="new-csv.r" Content-Disposition: attachment; filename="new-csv.r" Content-transfer-encoding: base64 UkVCT0wgWwoJVGl0bGU6CSJDb21tYS1TZXBhcmF0ZWQtVmFsdWVzIHRvIFJFQk9MIENvbnZlcnRl ciIKCURhdGU6CTUtU2VwLTIwMDAKCUF1dGhvcjoJIkJvaGRhbiBMZWNobm93c2t5IgoJRW1haWw6 CWJvQHJlYm9sLmNvbQoJRmlsZToJJW5ldy1jc3YucgoJUHVycG9zZTogewoJCUNvbnZlcnQgQ1NW IGZpbGVzLCBldmVuIHZlcnkgbGFyZ2Ugb25lcywgdG8gUkVCT0wgYmxvY2tzCgl9CglOb3Rlczog ewoJCUVhY2ggcmVjb3JkIGdldHMgb3V0cHV0IGFzIGl0cyBvd24gYmxvY2sgaW4gdGhlIG91dHB1 dCBmaWxlLgoJCVRoZSBjb2x1bW4gaGVhZGluZ3MgYXJlIHRoZSBmaXJzdCBibG9jayBpbiB0aGUg ZmlsZS4KCX0KCUNhdGVnb3J5OiBbZmlsZSB1dGlsIGRiIHRleHQgMl0KXQoKY3N2OiBvcGVuL2xp bmVzL2RpcmVjdCB0by1maWxlIGFzayAiRmlsZW5hbWUgdG8gY29udmVydCBmcm9tIENTVjogJSIK Y3N2LW91dDogdG8tZmlsZSBhc2sgIkZpbGVuYW1lIHRvIHNhdmUgY29udmVydGVkIGZpbGUgYXM6 ICUiCgp3cml0ZS9saW5lcyBjc3Ytb3V0IG1vbGQgcGFyc2UvYWxsIGZpcnN0IGNzdiAiLCIgO291 dHB1dHMgaGVhZGluZ3MgdG8gbmV3IGZpbGUKCmluZGV4OiAwCndoaWxlIFtmb3VuZD8gbGluZTog cGljayBjc3YgMV1bCglwcmluIFsiQ29udmVydGluZyByZWNvcmQiIGluZGV4OiBpbmRleCArIDEg Il5NIl0KCXdyaXRlL2xpbmVzL2FwcGVuZCBjc3Ytb3V0IG1vbGQgcGFyc2UvYWxsIGxpbmUgIiwi Cl0KY2xvc2UgY3N2CnByaW50ICJeL0RvbmUhIgo --0__=85256952004AC78E8f9e8a93df938690918c85256952004AC78E--