Re: Request for py program to insert space between two characters andsaved as text?

Discussion in 'Python' started by Dennis Lee Bieber, Dec 8, 2009.

  1. On Tue, 8 Dec 2009 08:26:58 +0530, 74yrs old <>
    declaimed the following in gmane.comp.python.general:

    > For Kannada project .txt(not .doc) is used, my requirement is to have one
    > space between two characters in Notepad file. In MSword there is provision
    > to make space between two characters under "Font" and can be saved as *.doc


    Microsoft Word is a word processor using graphical fonts... Spacing
    is a factor of playing with the character width in the rendering engine
    -- wide spacing in Word is NOT adding space characters.

    > * But when tried to save as* .txt* all formatting will disappear. I could
    > not understand how to do in notepad. Even tried copy and paste from doc to
    > notepad but failed.
    >

    Search and replace. Search and replace all "a" with "a ", repeat for
    "b", ..., and also for "A" by "A "... and any OTHER printable character
    that might appear.

    > In this context, I request you kindly for small python program - to make or


    Excuse me -- you want one of US to supply you with a program that
    will be used for YOUR entry to some job site? (At least, that's what I
    seem to be finding for "Kannada project")

    > insert space between two characters in the text file. (I have installed
    > FFedora-11 also ubuntu9.04)
    >

    And what does having two different LINUX operating systems have to
    do with this problem?

    How difficult is it to read a file character by character, and write
    a file containing that character and a space?


    --
    Wulfraed Dennis Lee Bieber KD6MOG
    HTTP://wlfraed.home.netcom.com/
    Dennis Lee Bieber, Dec 8, 2009
    #1
    1. Advertising

  2. Dennis Lee Bieber

    John Machin Guest

    On Dec 8, 6:56 pm, Dennis Lee Bieber <> wrote:
    > On Tue, 8 Dec 2009 08:26:58 +0530, 74yrs old <>
    > declaimed the following in gmane.comp.python.general:
    >
    > > For Kannada project .txt(not .doc) is used, my requirement is to have one
    > > space between two characters in Notepad file.  In MSword there is provision
    > > to make space between two characters under "Font" and  can be saved as *.doc
    > > *  But when tried to save as* .txt*  all formatting will disappear. I could
    > > not understand how to do in notepad. Even tried copy and paste from doc to
    > > notepad but failed.

    >
    > > In this context, I request you kindly for small python program - to make or

    >
    >         Excuse me -- you want one of US to supply you with a program that
    > will be used for YOUR entry to some job site? (At least, that's what I
    > seem to be finding for "Kannada project")


    http://en.wikipedia.org/wiki/Kannada_script

    I think "project" means any piece of software ...

    >
    > > insert space between two characters in the text file.

    >
    >         How difficult is it to read a file character by character, and write
    > a file containing that character and a space?


    Perhaps there are some subtleties of which we are unaware ...

    I would be very surprised if the OP could not find on a forum much
    closer to home more people who know more about using Indic scripts on
    computers than here.
    John Machin, Dec 8, 2009
    #2
    1. Advertising

  3. Dennis Lee Bieber

    steve Guest

    Re: Request for py program to insert space between two charactersand saved as text?

    On 12/08/2009 02:19 PM, John Machin wrote:
    >> [...snip...]

    > Perhaps there are some subtleties of which we are unaware ...
    >
    > I would be very surprised if the OP could not find on a forum much
    > closer to home more people who know more about using Indic scripts on
    > computers than here.


    That's true. I'd recommend that the original poster, posts the query at the
    bangalore python user group mailing list:

    http://mail.python.org/mailman/listinfo/bangpypers

    ....alongwith some additional details of the requirements. I am sure they
    wouldn't mind reading and replying to the question in kannada itself.

    After all Kannada is the language of the sate of Karnataka, of which Bangalore
    (or Bengaluru as it is known these days) is the capital city.

    cheers,
    - steve
    --
    random non tech spiel: http://lonetwin.blogspot.com/
    tech randomness: http://lonehacks.blogspot.com/
    what i'm stumbling into: http://lonetwin.stumbleupon.com/
    steve, Dec 8, 2009
    #3
  4. Dennis Lee Bieber

    John Machin Guest

    On Dec 8, 9:42 pm, steve <> wrote:
    > On 12/08/2009 02:19 PM, John Machin wrote:
    >
    > >> [...snip...]

    > > Perhaps there are some subtleties of which we are unaware ...

    >
    > > I would be very surprised if the OP could not find on a forum much
    > > closer to home more people who know more about using Indic scripts on
    > > computers than here.

    >
    > That's true. I'd recommend that the original poster, posts the query at the
    > bangalore python user group mailing list:
    >
    > http://mail.python.org/mailman/listinfo/bangpypers
    >
    > ...alongwith some additional details of the requirements. I am sure they
    > wouldn't mind reading and replying to the question in kannada itself.
    >
    > After all Kannada is the language of the sate of Karnataka, of which Bangalore
    > (or Bengaluru as it is known these days) is the capital city.


    Off-list, I've already solicited assistance for the OP from a
    prominent bangpyper.

    Cheers,
    John
    John Machin, Dec 8, 2009
    #4
  5. Dennis Lee Bieber

    r0g Guest

    Re: Request for py program to insert space between two charactersand saved as text?

    Dennis Lee Bieber wrote:
    > On Tue, 8 Dec 2009 08:26:58 +0530, 74yrs old <>
    > declaimed the following in gmane.comp.python.general:
    >
    >> For Kannada project .txt(not .doc) is used, my requirement is to have one

    <snip>
    >> In this context, I request you kindly for small python program - to make or

    >
    > Excuse me -- you want one of US to supply you with a program that
    > will be used for YOUR entry to some job site? (At least, that's what I
    > seem to be finding for "Kannada project")
    >



    Well it is only a 2 line program and he did ask nicely after all, if you
    begrudge him it then feel free to not answer, righteous indignation
    rarely helps anyone.

    Dear OP...

    Put the following 2 lines into a file and save it as spacer.py

    import sys
    print ' '.join([e for e in open(sys.argv[1], 'r').read()])


    Then open a terminal window and 'cd' to the same folder you just saved
    the spacer.py file in. Type...

    python spacer.py inputfile.txt > outputfile.txt

    This will run inputfile.txt through the space adding program we have
    just saved and then 'pipe' the output of that into a new file outputfile.txt

    Hope this helps,


    Roger Heathcote.
    r0g, Dec 8, 2009
    #5
  6. Dennis Lee Bieber

    Dave Angel Guest

    Re: Request for py program to insert space between two charactersand saved as text?

    r0g wrote:
    > Dennis Lee Bieber wrote:
    >
    >> On Tue, 8 Dec 2009 08:26:58 +0530, 74yrs old <>
    >> declaimed the following in gmane.comp.python.general:
    >>
    >>
    >>> For Kannada project .txt(not .doc) is used, my requirement is to have one
    >>>

    > <snip>
    >
    >>> In this context, I request you kindly for small python program - to make or
    >>>

    >> Excuse me -- you want one of US to supply you with a program that
    >> will be used for YOUR entry to some job site? (At least, that's what I
    >> seem to be finding for "Kannada project")
    >>
    >>

    >
    >
    > Well it is only a 2 line program and he did ask nicely after all, if you
    > begrudge him it then feel free to not answer, righteous indignation
    > rarely helps anyone.
    >
    > Dear OP...
    >
    > Put the following 2 lines into a file and save it as spacer.py
    >
    > import sys
    > print ' '.join([e for e in open(sys.argv[1], 'r').read()])
    >
    >
    > Then open a terminal window and 'cd' to the same folder you just saved
    > the spacer.py file in. Type...
    >
    > python spacer.py inputfile.txt > outputfile.txt
    >
    > This will run inputfile.txt through the space adding program we have
    > just saved and then 'pipe' the output of that into a new file outputfile.txt
    >
    > Hope this helps,
    >
    >
    > Roger Heathcote.
    >
    >

    That seems a bit dangerous to give to a beginner at Python, without
    discussing Unicode issues. If he's in Python 3.x, and if the default
    encoder is ASCII, which it seems to be most places, then he'll quickly
    get a conversion error for some character. And if it's some other 8 bit
    form, he might not get an error, but find that a space is inserted
    between two of the bytes of a UTF-8 code.

    DaveA
    Dave Angel, Dec 8, 2009
    #6
  7. Dennis Lee Bieber

    r0g Guest

    Re: Request for py program to insert space between two charactersand saved as text?

    Dave Angel wrote:
    >
    >
    > r0g wrote:
    >> Dennis Lee Bieber wrote:
    >>
    >>> On Tue, 8 Dec 2009 08:26:58 +0530, 74yrs old <>
    >>> declaimed the following in gmane.comp.python.general:
    >>>
    >>>
    >>>> For Kannada project .txt(not .doc) is used, my requirement is to
    >>>> have one
    >>>>

    >> <snip>
    >>
    >>>> In this context, I request you kindly for small python program - to
    >>>> make or
    >>>>
    >>> Excuse me -- you want one of US to supply you with a program that
    >>> will be used for YOUR entry to some job site? (At least, that's what I
    >>> seem to be finding for "Kannada project")
    >>>
    >>>

    >>
    >>
    >> Well it is only a 2 line program and he did ask nicely after all, if you
    >> begrudge him it then feel free to not answer, righteous indignation
    >> rarely helps anyone.
    >>
    >> Dear OP...
    >>
    >> Put the following 2 lines into a file and save it as spacer.py
    >>
    >> import sys
    >> print ' '.join([e for e in open(sys.argv[1], 'r').read()])
    >>
    >>
    >> Then open a terminal window and 'cd' to the same folder you just saved
    >> the spacer.py file in. Type...
    >>
    >> python spacer.py inputfile.txt > outputfile.txt
    >>
    >> This will run inputfile.txt through the space adding program we have
    >> just saved and then 'pipe' the output of that into a new file
    >> outputfile.txt
    >>
    >> Hope this helps,
    >>
    >>
    >> Roger Heathcote.
    >>
    >>

    > That seems a bit dangerous to give to a beginner at Python, without
    > discussing Unicode issues. If he's in Python 3.x, and if the default
    > encoder is ASCII, which it seems to be most places, then he'll quickly
    > get a conversion error for some character. And if it's some other 8 bit
    > form, he might not get an error, but find that a space is inserted
    > between two of the bytes of a UTF-8 code.
    >
    > DaveA
    >




    He said he's running the latest python and fedora, AFAIK the default for
    these systems is still the 2 series, not 3.


    Roger.
    r0g, Dec 9, 2009
    #7
  8. Dennis Lee Bieber

    Dave Angel Guest

    Re: Request for py program to insert space between two charactersand saved as text?

    r0g wrote:
    > Dave Angel wrote:
    >
    >> r0g wrote:
    >>
    >>> Dennis Lee Bieber wrote:
    >>>
    >>>
    >>>> On Tue, 8 Dec 2009 08:26:58 +0530, 74yrs old <>
    >>>> declaimed the following in gmane.comp.python.general:
    >>>>
    >>>>
    >>>>
    >>>>> For Kannada project .txt(not .doc) is used, my requirement is to
    >>>>> have one
    >>>>>
    >>>>>
    >>> <snip>
    >>>
    >>>
    >>>>> In this context, I request you kindly for small python program - to
    >>>>> make or
    >>>>>
    >>>>>
    >>>> Excuse me -- you want one of US to supply you with a program that
    >>>> will be used for YOUR entry to some job site? (At least, that's what I
    >>>> seem to be finding for "Kannada project")
    >>>>
    >>>>
    >>>>
    >>> Well it is only a 2 line program and he did ask nicely after all, if you
    >>> begrudge him it then feel free to not answer, righteous indignation
    >>> rarely helps anyone.
    >>>
    >>> Dear OP...
    >>>
    >>> Put the following 2 lines into a file and save it as spacer.py
    >>>
    >>> import sys
    >>> print ' '.join([e for e in open(sys.argv[1], 'r').read()])
    >>>
    >>>
    >>> Then open a terminal window and 'cd' to the same folder you just saved
    >>> the spacer.py file in. Type...
    >>>
    >>> python spacer.py inputfile.txt > outputfile.txt
    >>>
    >>> This will run inputfile.txt through the space adding program we have
    >>> just saved and then 'pipe' the output of that into a new file
    >>> outputfile.txt
    >>>
    >>> Hope this helps,
    >>>
    >>>
    >>> Roger Heathcote.
    >>>
    >>>
    >>>

    >> That seems a bit dangerous to give to a beginner at Python, without
    >> discussing Unicode issues. If he's in Python 3.x, and if the default
    >> encoder is ASCII, which it seems to be most places, then he'll quickly
    >> get a conversion error for some character. And if it's some other 8 bit
    >> form, he might not get an error, but find that a space is inserted
    >> between two of the bytes of a UTF-8 code.
    >>
    >> DaveA
    >>
    >>

    >
    >
    >
    > He said he's running the latest python and fedora, AFAIK the default for
    > these systems is still the 2 series, not 3.
    >
    >
    > Roger.
    >
    >

    That's even worse. As far as I can tell, the code will never do what he
    wants in Python 2.x. The Kannada text file is full of Unicode
    characters in some encoding, and if you ignore the encoding, you'll just
    get garbage.
    Dave Angel, Dec 9, 2009
    #8
  9. Dennis Lee Bieber

    r0g Guest

    Re: Request for py program to insert space between two charactersand saved as text?

    Dave Angel wrote:
    > r0g wrote:
    >> Dave Angel wrote:
    >>
    >>> r0g wrote:
    >>>
    >>>> Dennis Lee Bieber wrote:
    >>>>
    >>>>
    >>>>> On Tue, 8 Dec 2009 08:26:58 +0530, 74yrs old <>
    >>>>> declaimed the following in gmane.comp.python.general:
    >>>>>
    >>>>>
    >>>>>> For Kannada project .txt(not .doc) is used, my requirement is to
    >>>>>> have one
    >>>>>>
    >>>> <snip>
    >>>>
    >>>>
    >>>>>> In this context, I request you kindly for small python program - to
    >>>>>> make or
    >>>>>>
    >>>>> Excuse me -- you want one of US to supply you with a program that
    >>>>> will be used for YOUR entry to some job site? (At least, that's what I
    >>>>> seem to be finding for "Kannada project")
    >>>>>
    >>>>>
    >>>> Well it is only a 2 line program and he did ask nicely after all, if
    >>>> you
    >>>> begrudge him it then feel free to not answer, righteous indignation
    >>>> rarely helps anyone.
    >>>>
    >>>> Dear OP...
    >>>>
    >>>> Put the following 2 lines into a file and save it as spacer.py
    >>>>
    >>>> import sys
    >>>> print ' '.join([e for e in open(sys.argv[1], 'r').read()])
    >>>>
    >>>>
    >>>> Then open a terminal window and 'cd' to the same folder you just saved
    >>>> the spacer.py file in. Type...
    >>>>
    >>>> python spacer.py inputfile.txt > outputfile.txt
    >>>>
    >>>> This will run inputfile.txt through the space adding program we have
    >>>> just saved and then 'pipe' the output of that into a new file
    >>>> outputfile.txt
    >>>>
    >>>> Hope this helps,
    >>>>
    >>>>
    >>>> Roger Heathcote.
    >>>>
    >>>>
    >>> That seems a bit dangerous to give to a beginner at Python, without
    >>> discussing Unicode issues. If he's in Python 3.x, and if the default
    >>> encoder is ASCII, which it seems to be most places, then he'll quickly
    >>> get a conversion error for some character. And if it's some other 8 bit
    >>> form, he might not get an error, but find that a space is inserted
    >>> between two of the bytes of a UTF-8 code.
    >>>
    >>> DaveA
    >>>
    >>>

    >>
    >>
    >>
    >> He said he's running the latest python and fedora, AFAIK the default for
    >> these systems is still the 2 series, not 3.
    >>
    >>
    >> Roger.
    >>
    >>

    > That's even worse. As far as I can tell, the code will never do what he
    > wants in Python 2.x. The Kannada text file is full of Unicode
    > characters in some encoding, and if you ignore the encoding, you'll just
    > get garbage.
    >
    >


    Ah, fair enough. In my defence though I never saw the original post or
    this kannada.txt file as my newsserver is not so much with the
    reliability. I guess it's naive to assume an english .txt file is going
    to be in ASCII these days eh?

    I've yet to try python 3 yet either, this whole Unicode thing looks like
    it could be a total nightmare! :(

    Roger.
    r0g, Dec 9, 2009
    #9
  10. Dennis Lee Bieber

    Dave Angel Guest

    Re: Request for py program to insert space between two charactersand saved as text?

    r0g wrote:
    > Dave Angel wrote:
    >
    >> r0g wrote:
    >>
    >>> Dave Angel wrote:
    >>>
    >>>
    >>>> r0g wrote:
    >>>>
    >>>>
    >>>>> Dennis Lee Bieber wrote:
    >>>>>
    >>>>>
    >>>>>
    >>>>>> On Tue, 8 Dec 2009 08:26:58 +0530, 74yrs old <>
    >>>>>> declaimed the following in gmane.comp.python.general:
    >>>>>>
    >>>>>>
    >>>>>>
    >>>>>>> For Kannada project .txt(not .doc) is used, my requirement is to
    >>>>>>> have one
    >>>>>>>
    >>>>>>>
    >>>>> <big snip>
    >>>>>
    >>>
    >>>

    >> That's even worse. As far as I can tell, the code will never do what he
    >> wants in Python 2.x. The Kannada text file is full of Unicode
    >> characters in some encoding, and if you ignore the encoding, you'll just
    >> get garbage.
    >>
    >>
    >>

    >
    > Ah, fair enough. In my defence though I never saw the original post or
    > this kannada.txt file as my newsserver is not so much with the
    > reliability. I guess it's naive to assume an english .txt file is going
    > to be in ASCII these days eh?
    >
    > I've yet to try python 3 yet either, this whole Unicode thing looks like
    > it could be a total nightmare! :(
    >
    > Roger.
    >
    >

    But it isn't an english .txt file, it's a Kannada .txt file.
    Presumably you didn't realize that Kannada is a (non-English) language,
    spoken in parts of India, with several hundred characters. ASCII wasn't
    even an option. Anyway, no harm done, someone else referred the OP to a
    Python user-group local to that region.

    DaveA
    Dave Angel, Dec 9, 2009
    #10
  11. Dennis Lee Bieber

    r0g Guest

    Re: Request for py program to insert space between two charactersand saved as text?

    Dave Angel wrote:
    >
    >
    > r0g wrote:
    >> Dave Angel wrote:
    >>
    >>> r0g wrote:
    >>>
    >>>> Dave Angel wrote:
    >>>>
    >>>>
    >>>>> r0g wrote:
    >>>>>
    >>>>>> Dennis Lee Bieber wrote:
    >>>>>>
    >>>>>>
    >>>>>>> On Tue, 8 Dec 2009 08:26:58 +0530, 74yrs old
    >>>>>>> <>
    >>>>>>> declaimed the following in gmane.comp.python.general:
    >>>>>>>
    >>>>>>>
    >>>>>>>> For Kannada project .txt(not .doc) is used, my requirement is to
    >>>>>>>> have one
    >>>>>>>>
    >>>>>> <big snip>
    >>>>>>
    >>>>
    >>> That's even worse. As far as I can tell, the code will never do what he
    >>> wants in Python 2.x. The Kannada text file is full of Unicode
    >>> characters in some encoding, and if you ignore the encoding, you'll just
    >>> get garbage.
    >>>
    >>>
    >>>

    >>
    >> Ah, fair enough. In my defence though I never saw the original post or
    >> this kannada.txt file as my newsserver is not so much with the
    >> reliability. I guess it's naive to assume an english .txt file is going
    >> to be in ASCII these days eh?
    >>
    >> I've yet to try python 3 yet either, this whole Unicode thing looks like
    >> it could be a total nightmare! :(
    >>
    >> Roger.
    >>
    >>

    > But it isn't an english .txt file, it's a Kannada .txt file.
    > Presumably you didn't realize that Kannada is a (non-English) language,
    > spoken in parts of India, with several hundred characters. ASCII wasn't
    > even an option. Anyway, no harm done, someone else referred the OP to a
    > Python user-group local to that region.
    >
    > DaveA
    >


    Well this looked like English to me...

    example: *F o r K a n n a d a p r o j e c t . t x t(n o t .d o c) i s
    u s e d, m y r e q u i r e m e n t i s t o h a v e o n e s p a
    c e b e t w e e n t w o c h a r a c t e r s i n t h e t e x t.*

    ....but yes you're right, I had never heard of Kannada let alone knew it
    was another language!

    Roger.
    r0g, Dec 9, 2009
    #11
  12. Dennis Lee Bieber

    Dave Angel Guest

    Re: Request for py program to insert space between two charactersand saved as text?

    r0g wrote:
    > Dave Angel wrote:
    >
    >> r0g wrote:
    >>
    >>> Dave Angel wrote:
    >>>
    >>>
    >>>> r0g wrote:
    >>>>
    >>>>
    >>>>> Dave Angel wrote:
    >>>>>
    >>>>>
    >>>>>
    >>>>>> r0g wrote:
    >>>>>>
    >>>>>>
    >>>>>>> Dennis Lee Bieber wrote:
    >>>>>>>
    >>>>>>>
    >>>>>>>
    >>>>>>>> On Tue, 8 Dec 2009 08:26:58 +0530, 74yrs old
    >>>>>>>> <>
    >>>>>>>> declaimed the following in gmane.comp.python.general:
    >>>>>>>>
    >>>>>>>>
    >>>>>>>>
    >>>>>>>>> For Kannada project .txt(not .doc) is used, my requirement is to
    >>>>>>>>> have one
    >>>>>>>>>
    >>>>>>>>>
    >>>>>>> <big snip>
    >>>>>>>
    >>>>>>>
    >>>>>
    >>>>>
    >>>> That's even worse. As far as I can tell, the code will never do what he
    >>>> wants in Python 2.x. The Kannada text file is full of Unicode
    >>>> characters in some encoding, and if you ignore the encoding, you'll just
    >>>> get garbage.
    >>>>
    >>>>
    >>>>
    >>>>
    >>> Ah, fair enough. In my defence though I never saw the original post or
    >>> this kannada.txt file as my newsserver is not so much with the
    >>> reliability. I guess it's naive to assume an english .txt file is going
    >>> to be in ASCII these days eh?
    >>>
    >>> I've yet to try python 3 yet either, this whole Unicode thing looks like
    >>> it could be a total nightmare! :(
    >>>
    >>> Roger.
    >>>
    >>>
    >>>

    >> But it isn't an english .txt file, it's a Kannada .txt file.
    >> Presumably you didn't realize that Kannada is a (non-English) language,
    >> spoken in parts of India, with several hundred characters. ASCII wasn't
    >> even an option. Anyway, no harm done, someone else referred the OP to a
    >> Python user-group local to that region.
    >>
    >> DaveA
    >>
    >>

    >
    > Well this looked like English to me...
    >
    > example: *F o r K a n n a d a p r o j e c t . t x t(n o t .d o c) i s
    > u s e d, m y r e q u i r e m e n t i s t o h a v e o n e s p a
    > c e b e t w e e n t w o c h a r a c t e r s i n t h e t e x t.*
    >
    > ...but yes you're right, I had never heard of Kannada let alone knew it
    > was another language!
    >
    > Roger.
    >
    >

    There were two examples. The one you quoted was in English, and
    immediately afterward was the second one, presumably in Kannada.

    DaveA
    Dave Angel, Dec 9, 2009
    #12
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Shuo Xiang

    Stack space, global space, heap space

    Shuo Xiang, Jul 9, 2003, in forum: C Programming
    Replies:
    10
    Views:
    2,890
    Bryan Bullard
    Jul 11, 2003
  2. Christian Seberino
    Replies:
    21
    Views:
    1,653
    Stephen Horne
    Oct 27, 2003
  3. Ian Bicking
    Replies:
    2
    Views:
    1,009
    Steve Lamb
    Oct 23, 2003
  4. Ian Bicking
    Replies:
    2
    Views:
    723
    Michael Hudson
    Oct 24, 2003
  5. =?Utf-8?B?ZHc=?=
    Replies:
    5
    Views:
    1,119
    Alan Silver
    Jul 30, 2006
Loading...

Share This Page