472,951 Members | 1,802 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,951 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 1581
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

22
by: Ling Lee | last post by:
Hi all. I'm trying to write a program that: 1) Ask me what file I want to count number of lines in, and then counts the lines and writes the answear out. 2) I made the first part like this: ...
3
by: Albretch | last post by:
I am trying to insert some textual data belonging to an HTML page into a table column with 'TEXT' as data type mysql's maual _/manual.html#String_types tell you, you may insert up to (2^16 - 1),...
1
by: wtnt | last post by:
Hello. I've searched all over and haven't seen another thread with this problem. Please bear with me as I try to explain. thanks. :) I have some programs that need to be cross-platform...
8
by: Eric Lilja | last post by:
Hello, I had what I thought was normal text-file and I needed to locate a string matching a certain pattern in that file and, if found, replace that string. I thought this would be simple but I had...
7
by: Kueishiong Tu | last post by:
I have a text file with wide characters. I use the following C++ code to read them in. However the wide characters are read in properly. What is wrong? String* path = "C:\\Documents and...
4
by: Kueishiong Tu | last post by:
I have a text file with wide characters. I use the following C++ code to read them in. However the wide characters are not read in properly. What is wrong? String* path = "C:\\Documents and...
8
by: FUGATO | last post by:
I need to help in my assignment. I need to wrap a text with the following indications: 1.If you have reached the end of the line (number of characters on this line >= 40) AND you have reached the...
29
by: list | last post by:
Hi folks, I am new to Googlegroups. I asked my questions at other forums, since now. I have an important question: I have to check files if they are binary(.bmp, .avi, .jpg) or text(.txt,...
5
by: Davo1977 | last post by:
Analysing text files to obtain statistics on their content You are to write a Perl program that analyses text files to obtain statistics on their content. The program should operate as follows: ...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

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.