473,382 Members | 1,611 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

The importance of using Library Functions

At my company we have a program that parses through certain types of
electronic files and stores the information in plain text. E-mail
poses an interesting problem for us, because most of the text tends to
be wrapped and doesn't contain hard returns. The specific web control
we use to display this text will simply show the text of the e-mail as
a single continuous line.

On friday I was asked to fix the text for these files so it would be
appropriately wrapped at a line width of 80 characters. Yesterday I
began writing the code to deal with this. I was at work until 5:15 am
today trying to solve all the little quirks of that type of parsing.
I finally got most of the kinks worked out, and ran it, however at
great personal cost (ie lost sleep).

Much to my dismay I was browsing this board and saw the post about
Summer Reading:

On Tue, 12 Aug 2003 06:57:05 GMT, "Raymond Hettinger"
<vz******@verizon.net> wrote:
Found in a pamphlet at a pre-school:
---------------------------------------
Reading improves vocabulary
Reading raises cultural literacy through shared knowledge
Reading develops writing skills
Reading opens the mind to new ways of understanding
Reading is fun
Accordingly, I suggest the following works of literature:

* heapq.py (255 lines)
* sets.py (536 lines)
* textwrap.py (355 lines)
* csv.py (427 lines)


With a sinking feeling I opened the textwrap.py module and browsed
through it. After running several tests and playing with some of the
settings, this was *exactly* what I needed.

I've always enjoyed writing code. I particularly enjoy solving hard
problems, what I don't like is trying to solve them under immense
pressure from a client. Ultimately the problem itself was moderately
hard to solve, but the conditions made it even more difficult. I had
an inordinately large amount of text to deal with, so my test cycle
was ungodly slow.

Had I spent 30 minutes looking through the documentation, I could've
saved my self one helluva long night.

As much as I hate to be the example, it really is a wonderful
illustratration of why following the Unix / OSS development model is a
better way to go.

1. Check to see if someone has already written an app to do what you
want done.
2. Check to see if someone has written something that is close to what
you want done. If you can get the source code, modify it to do what
you need specifically.
3. Write it from scratch.

Instead of working my way down the list, I jumped straight to number
3. While that can be useful for an academic excercise, or when you
are going for a more rigorous approach, it's seldom useful when you
have a looming deadline.

Doug Tolton
Jul 18 '05 #1
1 4497
On Wed, 13 Aug 2003 02:26:18 GMT, Doug Tolton <dt*****@yahoo.com>
wrote:
At my company we have a program that parses through certain types of
electronic files and stores the information in plain text. E-mail
poses an interesting problem for us, because most of the text tends to
be wrapped and doesn't contain hard returns. The specific web control
we use to display this text will simply show the text of the e-mail as
a single continuous line.

On friday I was asked to fix the text for these files so it would be
appropriately wrapped at a line width of 80 characters. Yesterday I
began writing the code to deal with this. I was at work until 5:15 am
today trying to solve all the little quirks of that type of parsing.
I finally got most of the kinks worked out, and ran it, however at
great personal cost (ie lost sleep).

Much to my dismay I was browsing this board and saw the post about
Summer Reading:

On Tue, 12 Aug 2003 06:57:05 GMT, "Raymond Hettinger"
<vz******@verizon.net> wrote:
Found in a pamphlet at a pre-school:
---------------------------------------
Reading improves vocabulary
Reading raises cultural literacy through shared knowledge
Reading develops writing skills
Reading opens the mind to new ways of understanding
Reading is fun
Accordingly, I suggest the following works of literature:

* heapq.py (255 lines)
* sets.py (536 lines)
* textwrap.py (355 lines)
* csv.py (427 lines)


With a sinking feeling I opened the textwrap.py module and browsed
through it. After running several tests and playing with some of the
settings, this was *exactly* what I needed.

I've always enjoyed writing code. I particularly enjoy solving hard
problems, what I don't like is trying to solve them under immense
pressure from a client. Ultimately the problem itself was moderately
hard to solve, but the conditions made it even more difficult. I had
an inordinately large amount of text to deal with, so my test cycle
was ungodly slow.

Had I spent 30 minutes looking through the documentation, I could've
saved my self one helluva long night.

As much as I hate to be the example, it really is a wonderful
illustratration of why following the Unix / OSS development model is a
better way to go.

1. Check to see if someone has already written an app to do what you
want done.
2. Check to see if someone has written something that is close to what
you want done. If you can get the source code, modify it to do what
you need specifically.
3. Write it from scratch.

Instead of working my way down the list, I jumped straight to number
3. While that can be useful for an academic excercise, or when you
are going for a more rigorous approach, it's seldom useful when you
have a looming deadline.

Doug Tolton

Interestingly TextWrap choked on the text I'm running it against. I'm
sure it's more an issue of complete craziness in these files than an
actual problem with TextWrap.

While it doesn't change the fact that I should have approached the
problem differently at the outset, it makes me happy to know that I
didn't waste all that time writing my code.

Doug Tolton
Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: sks_cpp | last post by:
I am somewhat new to STL and the plethora of library functions they have. I looked at sgi's stl info. and I was overwhelmed so I thought I would present my question here. I have std::map<WWN*,...
4
by: junky_fellow | last post by:
what is the purpose of using library functions ? How could i know whether a particular function that i want to write already exists in the library ? Are there some standard functions which...
9
by: TheOne | last post by:
Would anyone please point me to a list of reentrant C library functions? I want to know which C library functions are safe to use inside a signal handler across all platforms. Does GNU C library...
13
by: Richard G. Riley | last post by:
In another thread it was pointed out that I'd made a booboo with strcpy : one that that I've, if I'm honest, made many times before. Not out of badness, just because since I first programmed C...
18
by: Anjana | last post by:
hi, can anyone illustrate a program to read and print a number without using standard library functions?? waiting for reply....
7
by: Francine.Neary | last post by:
This may well be implementation-defined or undefined behavior... if so, then of course that's a good enough answer. Consider the following situation: /* file1.c */ int (*f)(const char *,...
31
by: Francine.Neary | last post by:
One interesting thing to come out of the recent "Alignment" thread is that it is impossible to write a portable replacement for malloc in "user space" (not sure what the right term is - I mean an...
20
by: J de Boyne Pollard | last post by:
MThe library functions which are included to allow process Mlaunch, forking, and termination, imply that it is both Mpossible and desirable for a process to fork itself. This is Ma fundamental...
2
by: rams | last post by:
hi all i am keen to know where does the built in functions (library functions )like PRINTF(),MALLOC()..etc... are defined. as i know , header files contains only prototypes i am using gnu...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.