471,318 Members | 1,842 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,318 software developers and data experts.

Compressing a text file using count of continous characters

I need to count the number of continous character occurances(more than
1) in a file, and replace it with a compressed version, like below
XYZAAAAAAAADEFAAcdAA --XYZ8ADEF2Acd2A

Thanks
Sumod
Dec 14 '07 #1
4 1508
On Fri, 14 Dec 2007 08:54:58 -0800, nirvana wrote:
I need to count the number of continous character occurances(more than
1) in a file, and replace it with a compressed version, like below
XYZAAAAAAAADEFAAcdAA --XYZ8ADEF2Acd2A
Great. Then go ahead an implement it. :-)

`itertools.groupby()` might be handy.

And you have to think about digits in the source if that's allowed.

Ciao,
Marc 'BlackJack' Rintsch
Dec 14 '07 #2
On Dec 14, 2007 10:54 AM, nirvana <sm******@gmail.comwrote:
I need to count the number of continous character occurances(more than
1) in a file, and replace it with a compressed version, like below
XYZAAAAAAAADEFAAcdAA --XYZ8ADEF2Acd2A

This sounds like homework. Google for run length encoding for
algorithms, or check your textbook.
Dec 14 '07 #3
On Dec 14, 12:07 pm, "Chris Mellon" <arka...@gmail.comwrote:
On Dec 14, 2007 10:54 AM, nirvana <smkme...@gmail.comwrote:
I need to count the number of continous character occurances(more than
1) in a file, and replace it with a compressed version, like below
XYZAAAAAAAADEFAAcdAA --XYZ8ADEF2Acd2A

This sounds like homework. Google for run length encoding for
algorithms, or check your textbook.
nah, not homework... :). And yeah got it. And thanks for its name
(RLE), that saved a lot of googles....

Thanks
Dec 14 '07 #4
XYZAAAAAAAADEFAAcdAA --XYZ8ADEF2Acd2A
(RLE), that saved a lot of googles....
I have written a rle in my first years in school. It compresses a bitmap
image %50 compression is achivied :) The link :
http://arilaripi.org/index.php?optio...ileinfo&id=273

And it is delphi but code is easy... In python it will be easier of course :)
>
Thanks

Dec 15 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

22 posts views Thread by Ling Lee | last post: by
7 posts views Thread by Kueishiong Tu | last post: by
4 posts views Thread by Kueishiong Tu | last post: by
8 posts views Thread by FUGATO | last post: by
29 posts views Thread by list | last post: by
5 posts views Thread by Davo1977 | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.