Advertisements

Guest

On Tue, 24 Mar 2009 06:07:16 -0700 (PDT), ansher <> wrote:
>Hello
>
>What I am trying to achieve is to read a file and write the formatted
>text into a new file. But I am facing some difficulty with that
>
>Format: I am reading a file where line continuation is indicated by
>“+” sign at the beginning of the new line. Remove the line
>continuation and add (join) this new line to prev. one
>
>NOTE: file do not have line number, it is only for your reference.
>
>Line13: n01contacts/friends do you
>Line14: +have in each of the services ;c=contacts(433)’1’
>
>Output: n01 contacts/friends do you have in each of the
>services ;c=contacts(433)’1’
>
>Challenges: I cannot always consider “+”sign as the beginning of the
>new line, those instances are
>
>1.Section of lines should not be formatted after text ‘fld’, refer
>line 16-23 should not be formatted. Lines after this section must be
>formatted.
>
>2. Section of lines should not be formatted after text ‘val’, refer
>line 29-33 should not be formatted. Lines after this section must be
>formatted.
>
>3. Refer line 9-12, line 10 ends with ; but lines 11 & 12 do not.
> After formatting line should be separated by single ;
>
> *include q10.qin;txt=UNIQUENESS; bb=Top line; tx=Mid Value;tb=Low
>Value
>
>4.Refer line 13-14,
>
>Line13: n01contacts/friends do you
>Line14: +have in each of the services ;c=contacts(433)’1’
>
>After formatting line should not be separated by single ; instead it
>should read as
>
>n01contacts/friends do you have in each of the services ;c=contacts
>(433)’1’
>
>
>Any solution to this will be of great help to me. Thanks

But what about ';' ?
Sure the sample in this form can be done. Not quite so simple
though. The rules you specify are not quite distinct.

Advertisements

ansher <> wrote:
> Format: I am reading a file where line continuation is indicated by
> ?+? sign at the beginning of the new line. Remove the line
> continuation and add (join) this new line to prev. one
> Challenges: I cannot always consider ?+?sign as the beginning of the
> new line, those instances are
>
> 1.Section of lines should not be formatted after text ?fld?, refer
> line 16-23 should not be formatted. Lines after this section must be
> formatted.
>
> 2. Section of lines should not be formatted after text ?val?, refer
> line 29-33 should not be formatted. Lines after this section must be
> formatted.

I'll do that part for you.

> 3. Refer line 9-12, line 10 ends with ; but lines 11 & 12 do not.
> After formatting line should be separated by single ;
>
> *include q10.qin;txt=UNIQUENESS; bb=Top line; tx=Mid Value;tb=Low
> Value
>
> 4.Refer line 13-14,
>
> Line13: n01contacts/friends do you
> Line14: +have in each of the services ;c=contacts(433)?1?
>
> After formatting line should not be separated by single ; instead it
> should read as
>
> n01contacts/friends do you have in each of the services ;c=contacts
> (433)?1?

I'll leave that so that you have the opportunity to write some code
yourself, unless you plan to send me your paycheck.

>> > 3. Refer line 9-12, line 10 ends with ; but lines 11 & 12 do not.
>> > After formatting line should be separated by single ;
>>
>> > *include q10.qin;txt=UNIQUENESS; bb=Top line; tx=Mid Value;tb=Low
>> > Value
>>
>> > 4.Refer line 13-14,
>>
>> > Line13: n01contacts/friends do you
>> > Line14: +have in each of the services ;c=contacts(433)?1?
>>
>> > After formatting line should not be separated by single ; instead it
>> > should read as
>>
>> > n01contacts/friends do you have in each of the services ;c=contacts
>> > (433)?1?
>>
>> I'll leave that so that you have the opportunity to write some code
>> yourself, unless you plan to send me your paycheck.

> This code works but there are few formatting conditions not taken care
> of, like it do not add single ; after joining lines.

Right.

Did you read what I wrote?

You must either learn to program in Perl, hire someone to do it
for you, or abandon getting it done.

On Mar 25, 4:36 am, Tad J McClellan <> wrote:
> >> I'll leave that so that you have the opportunity to write some code
> >> yourself, unless you plan to send me your paycheck.
> > This code works but there are few formatting conditions not taken care
> > of, like it do not add single ; after joining lines.
>
> Right.
>
> Did you read what I wrote?
>
> You must either learn to program in Perl, hire someone to do it
> for you, or abandon getting it done.
>
> --
> Tad McClellan
> email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"- Hide quoted text -
>
> - Show quoted text -

Didnt mean any offence, I was just sharing information with you after
using the code.

Share This Page

Welcome to The Coding Forums!

Welcome to the Coding Forums, the place to chat about anything related to programming and coding languages.

Please join our friendly community by clicking the button below - it only takes a few seconds and is totally free. You'll be able to ask questions about coding or chat with the community and help others.
Sign up now!