Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Adding a delimiter inbetween number characters and letter characters

Reply
Thread Tools

Adding a delimiter inbetween number characters and letter characters

 
 
toomanyjoes@mail.utexas.edu
Guest
Posts: n/a
 
      01-12-2005
Hi,

I just posted a message on deleting newline characters in perl.


I used this code to do that:
perl -pe "chomp;print $/ if $.>1 and /^\d/" file1 > file2

I ended up with a new text file in this format:

1sampletextsampletextsamplet22tsampletextsampletex tsampletext
2sampletextsampletextsampletextsam56etextsampletex tsampletext
3sampletextsampletextsampletextsampletextsampletex tsampletext
8sampletextsampletextsampletex765mpletextsampletex tsampletext
9sampletextsampletextsampletextsampletextsampletex tsampletext
15sampletextsampletextsampletextsampletextsamplete xtsampletextsampletextsampletextsampletextsample32 4tsampletextsampletext
....

Now what I want is to add a delimiter inbetween the number at the
beginning of the line and the text. The number however could be any
number of digits long. So for instance if I use a "/" as a delimiter
the text would look like this.

1/sampletextsampletextsamplet22tsampletextsampletext sampletext
2/sampletextsampletextsampletextsam56etextsampletext sampletext
3/sampletextsampletextsampletextsampletextsampletext sampletext
8/sampletextsampletextsampletex765mpletextsampletext sampletext
9/sampletextsampletextsampletextsampletextsampletext sampletext
15/sampletextsampletextsampletextsampletextsampletext sampletextsampletextsampletextsampletextsample324t sampletextsampletext

This way I can go from a text file to Excel and then into a database.
Could anyone help me with this?

Thanks,
Joe

 
Reply With Quote
 
 
 
 
Paul Lalli
Guest
Posts: n/a
 
      01-12-2005
<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> I ended up with a new text file in this format:
>
> 1sampletextsampletextsamplet22tsampletextsampletex tsampletext
> 2sampletextsampletextsampletextsam56etextsampletex tsampletext
> 3sampletextsampletextsampletextsampletextsampletex tsampletext
> 8sampletextsampletextsampletex765mpletextsampletex tsampletext
> 9sampletextsampletextsampletextsampletextsampletex tsampletext
>

15sampletextsampletextsampletextsampletextsamplete xtsampletextsampletext
sampletextsampletextsample324tsampletextsampletext
> ...
>
> Now what I want is to add a delimiter inbetween the number at the
> beginning of the line and the text. The number however could be any
> number of digits long. So for instance if I use a "/" as a delimiter
> the text would look like this.
>
> 1/sampletextsampletextsamplet22tsampletextsampletext sampletext
> 2/sampletextsampletextsampletextsam56etextsampletext sampletext
> 3/sampletextsampletextsampletextsampletextsampletext sampletext
> 8/sampletextsampletextsampletex765mpletextsampletext sampletext
> 9/sampletextsampletextsampletextsampletextsampletext sampletext
>

15/sampletextsampletextsampletextsampletextsampletext sampletextsampletex
tsampletextsampletextsample324tsampletextsampletex t
>
> This way I can go from a text file to Excel and then into a database.
> Could anyone help me with this?


This is a trivial operation using regular expressions and
search-and-replace. I suggest you read up:

perldoc perlretut
perldoc perlrequick
perldoc perlre

Paul Lalli

 
Reply With Quote
 
 
 
 
toomanyjoes@mail.utexas.edu
Guest
Posts: n/a
 
      01-12-2005
Anyone can feel free to post helpful messages despite Paul Lalli's
post. I realize it is trivial, I'm not a Perl programmer, and I am
reading up, but my project is waiting for this one simple task to be
completed before moving on so the faster I figure this out the better.
Paul if its so easy why not code to do it? I suggest you read up on
newsgroup etiquette.

 
Reply With Quote
 
toomanyjoes@mail.utexas.edu
Guest
Posts: n/a
 
      01-12-2005
Anyone can feel free to post helpful messages despite Paul Lalli's
post. I realize it is trivial, I'm not a Perl programmer, and I am
reading up, but my project is waiting for this one simple task to be
completed before moving on so the faster I figure this out the better.
Paul if its so easy why not post code to do it? I suggest YOU read up
on newsgroup etiquette.

 
Reply With Quote
 
Scott Bryce
Guest
Posts: n/a
 
      01-12-2005
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:

> Anyone can feel free to post helpful messages despite Paul Lalli's
> post. I realize it is trivial, I'm not a Perl programmer, and I am
> reading up, but my project is waiting for this one simple task to be
> completed before moving on so the faster I figure this out the better.
> Paul if its so easy why not post code to do it? I suggest YOU read up
> on newsgroup etiquette.


Paul gave you good advice. You can learn more from the docs than you can
learn from blindly copying code. Paul showed you exactly where to read
in the docs.

Perhaps you should read the posting guidelines for this group. Now that
you have insulted Paul, you are probably on your own.


 
Reply With Quote
 
Paul Lalli
Guest
Posts: n/a
 
      01-12-2005
<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> Anyone can feel free to post helpful messages despite Paul Lalli's
> post.


My post was extremely helpful.

> I realize it is trivial, I'm not a Perl programmer, and I am
> reading up, but my project is waiting for this one simple task to be
> completed before moving on


The failure of your project coordinator to hire correct staff is not
justification for asking this group to do your project's work for you.

> so the faster I figure this out the better.


The better for you, perhaps. The better for the rest of the people
reading this group, not so much, no.

> Paul if its so easy why not post code to do it?


Because I *know* how to do it. I am not the one who needs to learn.

> I suggest YOU read up on newsgroup etiquette.


Really? Would that etiquette include such things as posting the same
message twice? Would it include not reading the posting guidelines for
the group? Would it include not quoting the material your are
responding to?

Please do go read those guidelines. Then try to understand that this is
not a group where it is acceptable to ask "Someone please do this for
me." This is a group where beginners are encouraged to ask for help or
understanding when it comes to *learning* the Perl language.

Paul Lalli

 
Reply With Quote
 
toomanyjoes@mail.utexas.edu
Guest
Posts: n/a
 
      01-12-2005
In spite of Scotts message anyone can feel free to post useful
information. Scott, I already knew about those references. I've been
going through them. My post did not violate any rules for this group, I
have read those too. I am not new to newgroups, only to the Perl
language. You guys could make someone new here a little more
comfortable posting questions. Rather than more people telling me how
little I know about Perl, I would be much oblidged to anyone who can
post a little snippet of code for me.

 
Reply With Quote
 
toomanyjoes@mail.utexas.edu
Guest
Posts: n/a
 
      01-12-2005
In spite of Scotts message anyone can feel free to post useful
information. Scott, I already knew about those references. I've been
going through them. My post did not violate any rules for this group, I
have read those too. I am not new to newgroups, only to the Perl
language. You guys could make someone new here a little more
comfortable posting questions. Rather than more people telling me how
little I know about Perl, I would be much oblidged to anyone who can
post a little snippet of code for me.

 
Reply With Quote
 
toomanyjoes@mail.utexas.edu
Guest
Posts: n/a
 
      01-12-2005
I'm not going to let my temper get the better of me Paul, like you just
did. Showing the passion of your emotions is very unattractive in
groups like this. Perhaps my "project coordinator" hired the wrong
"staff", true. But the facts are:

1) I have to get this done
2) Your post was of no help to me
3) I still need help

I hope you will accept an apology for insulting you. I have read the
guidelines for this group. I've been posting on these groups for over
10 years back when it was DejaNews and it has and probably will remain
a forum to ask people to write code for you, many people learn this way.

 
Reply With Quote
 
Sherm Pendley
Guest
Posts: n/a
 
      01-12-2005
(E-Mail Removed) wrote:

> In spite of Scotts message anyone can feel free to post useful
> information.


You can keep parroting that cute little catch-phrase of yours all you want -
the fact remains that the people you're berating *did* post useful
information.

Frankly, given your attitude, I'd imagine it's the last useful information
you'll get from this group.

> You guys could make someone new here a little more
> comfortable posting questions.


Making people comfortable posting questions not our goal here. Our goal is
to make people comfortable with the docs, so they don't have to post
questions.

To put it another way, if you've come looking for free fish, you're in the
wrong place. We give fishing lessons here.

> I would be much oblidged to anyone who can
> post a little snippet of code for me.


If you want code written to spec, email me privately for my consulting
rates.

sherm--

--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
difference inbetween macro & function jason C Programming 6 11-08-2007 03:36 PM
big letter -> small letter vertigo Python 4 07-06-2004 07:23 AM
Error Pages, Static Error Variables and all the stuff inbetween Girish ASP .Net 3 02-24-2004 05:37 PM
Interrogating string for number of characters, response.writing identical number of characters on new line Ken Fine ASP General 2 02-05-2004 03:40 AM
XML DOM - getting data inbetween tags Mike Miller Java 1 10-19-2003 04:59 PM



Advertisments