delimiting text file??

Jim Bruer jim at bruer.org
Thu Oct 14 20:45:56 EDT 1999


Aahz Maruch wrote:

> In article <7u5da5$pp2$1 at nntp6.u.washington.edu>,
> Donn Cave  <donn at u.washington.edu> wrote:
> >Quoth Gerrit Holl <gerrit.holl at pobox.com>:
> >| Aahz Maruch:
> >[re how to insert comma delimiters]
> >
> >|> delimitedString = string[:x] + "," + string[x:]
> >|>
> >|> That's a rather lame way to do it; as you learn more about Python,
> >|> you'll come across better ways.
> >|
> >| Is it? I think I've learned more about Python than Jim has (already finished
> >| Learning python, and I'm waiting for Programming TkInter with Python now),
> >| but I don't know a better way than this?
> >
> >He may have gauged better than I the original poster's zeal for
> >discovering things on his own, but I was surprised no one mentioned
> >string.join'ing a list of fields in one step.  It's what I consider
> >the normal approach to this common task.  Easier on the eyes, probably
> >faster if there are more than a couple of fields.
>
> Oh, I agree -- but the original poster didn't say anything about a list
> of fields....
> --

Thank you all for your suggestions. I'm impressed with Python and now this
friendly, helpful group.
I will ultimately use my program to delimit files of up to 1.0 million records,
each line composed of 1560 characters to be delimited into 230 fields.






More information about the Python-list mailing list