delimiting text file??

Aahz Maruch aahz at netcom.com
Wed Oct 13 18:23:17 EDT 1999


In article <3804F889.30739C22 at bruer.org>, Jim Bruer  <jim at bruer.org> wrote:
>
>I've made it through the first 3 chapters of, Learning Python and
>various online tutorials. With some excitement I'm trying to write my
>FIRST program which will read a text file and comma delimit it, so it
>can be read into a database table. I can read and write the file (line
>by line) ok, but:
>
>How do you insert a delimiter into a string at a given position?
>
>Tried "f.insert(i,x)" then realized this is for mutable sequences.This
>is so stupid I'm embarrassed to ask.

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.
--
                      --- Aahz (@netcom.com)

Androgynous poly kinky vanilla queer het    <*>      http://www.rahul.net/aahz/
Hugs and backrubs -- I break Rule 6  (if you want to know, do some research)




More information about the Python-list mailing list