delimiting text file??

Al Christians achrist at easystreet.com
Fri Oct 15 12:14:36 EDT 1999


If you are doing this enough to take efficiency seriously, go to
deja.com and look at the thread we had on 

	"string.join() vs % and + operators"

about six months ago.  There were some examples posted by the experts,
along with some timings, etc.  Basically the same subject as this
thread.


Al

Jim Bruer wrote:
> 
> 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