Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #40227 > unrolled thread
| Started by | idy <idhayham@gmail.com> |
|---|---|
| First post | 2013-02-28 22:49 -0800 |
| Last post | 2013-02-28 23:08 -0800 |
| Articles | 6 — 3 participants |
Back to article view | Back to comp.lang.python
text formatting question idy <idhayham@gmail.com> - 2013-02-28 22:49 -0800
Re: text formatting question Chris Angelico <rosuav@gmail.com> - 2013-03-01 17:53 +1100
Re: text formatting question idy <idhayham@gmail.com> - 2013-02-28 23:08 -0800
Re: text formatting question Dave Angel <davea@davea.name> - 2013-03-01 08:52 -0500
Re: text formatting question Chris Angelico <rosuav@gmail.com> - 2013-03-02 00:57 +1100
Re: text formatting question idy <idhayham@gmail.com> - 2013-02-28 23:08 -0800
| From | idy <idhayham@gmail.com> |
|---|---|
| Date | 2013-02-28 22:49 -0800 |
| Subject | text formatting question |
| Message-ID | <0a6178f9-51ef-4edc-b87f-2631d667797f@googlegroups.com> |
I have a text string of this format Error = 'XYC.12345455LOcation/user/data/MYGLE-INGXYC.23344566LOcation/user/data/INGE-FTYXYC.22334566LOcation/user/data/GETN-YUNXYC.12345455LOcation/user/data/MYGLE-INGXYC.1111111LOcation/user/data/INGE-FTYXYC.3333333LOcation/user/data/GETN-YUN' I need to write this to mail body as with following format in multiple lines XYC.12345455-LOcation/user/data/MYGLE-ING XYC.23344566-LOcation/user/data/INGE-FTY XYC.22334566LOcation/user/data/GETN-YUN XYC.12345455LOcation/user/data/MYGLE-ING XYC.1111111LOcation/user/data/INGE-FTY XYC.3333333LOcation/user/data/GETN-YUN Note (XYC is common for all the text , rest of the fields are not constant. Please help
[toc] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2013-03-01 17:53 +1100 |
| Message-ID | <mailman.2703.1362120831.2939.python-list@python.org> |
| In reply to | #40227 |
On Fri, Mar 1, 2013 at 5:49 PM, idy <idhayham@gmail.com> wrote:
> Error = 'XYC.12345455LOcation/user/data/MYGLE-INGXYC.23344566LOcation/user/data/INGE-FTYXYC.22334566LOcation/user/data/GETN-YUNXYC.12345455LOcation/user/data/MYGLE-INGXYC.1111111LOcation/user/data/INGE-FTYXYC.3333333LOcation/user/data/GETN-YUN'
>
> I need to write this to mail body as with following format in multiple lines
>
> XYC.12345455-LOcation/user/data/MYGLE-ING
> XYC.23344566-LOcation/user/data/INGE-FTY
> XYC.22334566LOcation/user/data/GETN-YUN
> XYC.12345455LOcation/user/data/MYGLE-ING
> XYC.1111111LOcation/user/data/INGE-FTY
> XYC.3333333LOcation/user/data/GETN-YUN
You want to break the line immediately before the 'XYC'? That's quite
easy; the line break is a character like any other, and can be used in
a replace() call:
formatted_error = Error.replace("XYC","\nXYC")
If that's not the case, can you clarify what you need to do to divide it?
Chris Angelico
[toc] | [prev] | [next] | [standalone]
| From | idy <idhayham@gmail.com> |
|---|---|
| Date | 2013-02-28 23:08 -0800 |
| Message-ID | <0a682b8c-34dd-4f45-b834-76c9f83d866d@googlegroups.com> |
| In reply to | #40228 |
On Friday, March 1, 2013 12:23:41 PM UTC+5:30, Chris Angelico wrote:
> On Fri, Mar 1, 2013 at 5:49 PM, idy <idhayham@gmail.com> wrote:
>
> > Error = 'XYC.12345455LOcation/user/data/MYGLE-INGXYC.23344566LOcation/user/data/INGE-FTYXYC.22334566LOcation/user/data/GETN-YUNXYC.12345455LOcation/user/data/MYGLE-INGXYC.1111111LOcation/user/data/INGE-FTYXYC.3333333LOcation/user/data/GETN-YUN'
>
> >
>
> > I need to write this to mail body as with following format in multiple lines
>
> >
>
> > XYC.12345455-LOcation/user/data/MYGLE-ING
>
> > XYC.23344566-LOcation/user/data/INGE-FTY
>
> > XYC.22334566LOcation/user/data/GETN-YUN
>
> > XYC.12345455LOcation/user/data/MYGLE-ING
>
> > XYC.1111111LOcation/user/data/INGE-FTY
>
> > XYC.3333333LOcation/user/data/GETN-YUN
>
>
>
> You want to break the line immediately before the 'XYC'? That's quite
>
> easy; the line break is a character like any other, and can be used in
>
> a replace() call:
>
>
>
> formatted_error = Error.replace("XYC","\nXYC")
>
>
>
> If that's not the case, can you clarify what you need to do to divide it?
>
>
>
> Chris Angelico
Chris,
Thanks this works great !!!
[toc] | [prev] | [next] | [standalone]
| From | Dave Angel <davea@davea.name> |
|---|---|
| Date | 2013-03-01 08:52 -0500 |
| Message-ID | <mailman.2721.1362145995.2939.python-list@python.org> |
| In reply to | #40229 |
On 03/01/2013 02:08 AM, idy wrote:
> On Friday, March 1, 2013 12:23:41 PM UTC+5:30, Chris Angelico wrote:
>>
>>
>>> <snip>
>>
>> You want to break the line immediately before the 'XYC'? That's quite
>> easy; the line break is a character like any other, and can be used in
>> a replace() call:
>>
>> formatted_error = Error.replace("XYC","\nXYC")
>>
>> If that's not the case, can you clarify what you need to do to divide it?
>>
>> Chris Angelico
>
> Chris,
>
> Thanks this works great !!!
>
The assumption Chris made is that the characters XYC do *not* appear
anywhere else in each string. if they do, then you need to write a spec
as to what criteria you can count on for the data.
If somebody has mangled all those lines into one long string, it's quite
likely that they CANNOT be reliably separated again. Chris' suggestion
is the most likely candidate, but ...
--
DaveA
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2013-03-02 00:57 +1100 |
| Message-ID | <mailman.2722.1362146236.2939.python-list@python.org> |
| In reply to | #40229 |
On Sat, Mar 2, 2013 at 12:52 AM, Dave Angel <davea@davea.name> wrote: > The assumption Chris made is that the characters XYC do *not* appear > anywhere else in each string. if they do, then you need to write a spec as > to what criteria you can count on for the data. > Right. I should have mentioned that. Let's hope the OP is sufficiently lucky as to have a separator uniqueness.. ChrisA
[toc] | [prev] | [next] | [standalone]
| From | idy <idhayham@gmail.com> |
|---|---|
| Date | 2013-02-28 23:08 -0800 |
| Message-ID | <mailman.2704.1362121746.2939.python-list@python.org> |
| In reply to | #40228 |
On Friday, March 1, 2013 12:23:41 PM UTC+5:30, Chris Angelico wrote:
> On Fri, Mar 1, 2013 at 5:49 PM, idy <idhayham@gmail.com> wrote:
>
> > Error = 'XYC.12345455LOcation/user/data/MYGLE-INGXYC.23344566LOcation/user/data/INGE-FTYXYC.22334566LOcation/user/data/GETN-YUNXYC.12345455LOcation/user/data/MYGLE-INGXYC.1111111LOcation/user/data/INGE-FTYXYC.3333333LOcation/user/data/GETN-YUN'
>
> >
>
> > I need to write this to mail body as with following format in multiple lines
>
> >
>
> > XYC.12345455-LOcation/user/data/MYGLE-ING
>
> > XYC.23344566-LOcation/user/data/INGE-FTY
>
> > XYC.22334566LOcation/user/data/GETN-YUN
>
> > XYC.12345455LOcation/user/data/MYGLE-ING
>
> > XYC.1111111LOcation/user/data/INGE-FTY
>
> > XYC.3333333LOcation/user/data/GETN-YUN
>
>
>
> You want to break the line immediately before the 'XYC'? That's quite
>
> easy; the line break is a character like any other, and can be used in
>
> a replace() call:
>
>
>
> formatted_error = Error.replace("XYC","\nXYC")
>
>
>
> If that's not the case, can you clarify what you need to do to divide it?
>
>
>
> Chris Angelico
Chris,
Thanks this works great !!!
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web