comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Problem with large .txt file
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Problem with large .txt file [message #55136 is a reply to message #55044] Tue, 31 July 2007 11:06 Go to previous message
Conor is currently offline  Conor
Messages: 138
Registered: February 2007
Senior Member
On Jul 31, 1:36 pm, Conor <cmanc...@gmail.com> wrote:
> On Jul 31, 1:15 pm, hradilv <hrad...@yahoo.com> wrote:
>
>
>
>> On Jul 31, 11:27 am, "Haje Korth" <haje.ko...@nospam.jhuapl.edu>
>> wrote:
>
>>> set i ti i=0l (make it a long)
>
>>> H.
>
>>> <aleks.fra...@gmail.com> wrote in message
>
>>> news:1185897834.196562.301440@57g2000hsv.googlegroups.com...
>
>>>> Hy there!
>>>> I have a large txt file (6.384KB) with 65000 lines. It's very large.
>>>> I need to open it, read every line, replace the spaces for commas, and
>>>> write the result in an output.txt
>
>>>> The code is ok. The problem is that idl crashes on line 7208. There's
>>>> a memory problem there.
>
>>>> Is there any way to do for all the lines of the txt file?? I don't
>>>> know how to deal with memory problems. Sorry!
>
>>>> I'm doing like this
>
>>>> :-----------------CUT HERE--------------------
>>>> i=0
>>>> line=''
>>>> ; Open the text file:
>>>> OPENR, inunit, '60mil_equal.txt', /GET_LUN
>>>> ; Open the terminal as a file:
>>>> OPENW, outunit, 'output.txt', /GET_LUN
>>>> ;================================
>>>> WHILE ~EOF(inunit) DO BEGIN
>>>> READF, inunit, line
>>>> line = STRJOIN(STRSPLIT(line, /EXTRACT), ', ')
>>>> PRINTF, outunit, line
>>>> i =i+1
>>>> ENDWHILE
>
>>>> FREE_LUN, inunit
>>>> FREE_LUN, outunit
>
>>>> END
>>>> :-----------------CUT HERE--------------------
>
>>>> Thank you very much
>
>> Or just use sed... Right tool for the right job.
>
> I was going to say use perl, but I suppose that's a bit simpler.
>
> sed 's/ /,/g' < 60mil_equal.txt > output.txt
>
> viola! Simple and elegant.
>
> Of course, considering that your files have a .txt extension, it seems
> likely that you are on a windows machine, and therefore have no access
> to sed. In that case, I would recommend learning perl, which can
> easily be installed on windows. A better option would be to just use
> linux or mac :)

Also, you could do this same thing in just about any text editor.
Even Microsoft Word has a find/replace option which would easily do
this. Notepad might too. I mention this simply because IDL really
isn't the best language for string parsing/editing. Other than that,
I'm afraid I'm out of suggestions. I don't see any problems with your
code.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: diferent results in program and envi
Next Topic: speed, size, contouring

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sun Oct 12 14:55:55 PDT 2025

Total time taken to generate the page: 1.19953 seconds