Replace in large text file ?

hiral hiralsmaillist at gmail.com
Wed Jun 9 06:27:36 EDT 2010


On Jun 6, 7:27 am, Steve <vvw... at googlemail.com> wrote:
> On 5 June, 08:53, Steve <vvw... at googlemail.com> wrote:
>
> > I am new to Python and am wanting  to replace characters in a very
> > large text file.....6 GB
> > In plain language what I wish to do is:
>
> > Remove all comma's
> > Replace all @ with comma's
> > Save as a new file.
>
> > Any of you clever people know the best way to do this......idiot guide
> > please.
>
> > Thanks
>
> > Steve
>
> Many thanks for your suggestions.
>
> sed -i 's/Hello/hello/g' file
>
> Run twice on the CL..with the hello's changed for my needs did it in a
> few minutes ,
>
> Again thanks
>
> Steve

Hi Steve,

You can do...

sed "s/,//g" <your_file> | sed "s/@/,/g" > <new_file>

Thank you.



More information about the Python-list mailing list