Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Applications > Turn list of numbers into a series of numbers ?

Turn list of numbers into a series of numbers ?
Thread Tools
Mac Elite
Join Date: May 2002
Location: Los Angeles, CA.
Status: Offline
Reply With Quote
Sep 11, 2003, 11:25 PM
 
I have a long list of numbers in a notepad file (each line contains a 5 digit number). It would take me forever to put this list of numbers into a series of numbers with commas separating them.

example:

i have .....

12345
12134
12312

i want ....

12345, 12134, 12312




Does anyone happen to know of a program that can render this quickly? thanks for any help!!!!!

     
Moderator Emeritus
Join Date: Nov 2000
Location: Illinois
Status: Offline
Reply With Quote
Sep 11, 2003, 11:59 PM
 
You can do it in excel if you have it. Just copy all of the numbers to the clipboard and paste them into excel (they should come out with one five-digit number per cell). Then go to format cell, and choose "user setting" (or something like that, I'm using Japanese Office, so I don't have the exact English term). Put this into the box:

00000","

That should make all of the numbers have a comma after them. Then copy all of the numbers in excel and paste them into a text editor like TextEdit. When I did it with your sample, it came up with:

12345,12134,12312,
     
Mac Enthusiast
Join Date: Feb 2003
Location: Portland, Oregon
Status: Offline
Reply With Quote
Sep 12, 2003, 12:56 AM
 
I wrote a quick 'n dirty C++ program to to parse that file for you, message me via
aim: jessejlt
if you want it.
jesse ;-)
     
Addicted to MacNN
Join Date: Apr 2001
Location: europe
Status: Offline
Reply With Quote
Sep 12, 2003, 01:09 AM
 
I think I would have used a text editor to replace "\n" with ", ".
Nasrudin sat on a river bank when someone shouted to him from the opposite side: "Hey! how do I get across?" "You are across!" Nasrudin shouted back.
     
badtz  (op)
Mac Elite
Join Date: May 2002
Location: Los Angeles, CA.
Status: Offline
Reply With Quote
Sep 12, 2003, 01:23 AM
 
seriously! thanks for both of the feedback!

BOTH methods worked beautifully!!!!!


     
Professional Poster
Join Date: Oct 2001
Location: London
Status: Offline
Reply With Quote
Sep 12, 2003, 04:43 AM
 
Originally posted by Developer:
I think I would have used a text editor to replace "\n" with ", ".
Wow - I would never have thought that Search and Replace could do control chars.

nice tip.
     
Grizzled Veteran
Join Date: Jan 2002
Location: Melbourne, Australia
Status: Offline
Reply With Quote
Sep 12, 2003, 05:36 AM
 
Originally posted by Diggory Laycock:
Wow - I would never have thought that Search and Replace could do control chars.

nice tip.
Certainly does, the other option is to copy the new line/tab or whatever and paste it into the find/replace dialog. Oh and while we're offering solutions this little awk script would probably have done it too:
awk '{ printf "%s, ", $1 } END { print }' numbers.txt
(Last edited by WJMoore; Sep 12, 2003 at 05:43 AM. )
     
Mac Elite
Join Date: Jul 2000
Location: Dallas, TX, USA
Status: Offline
Reply With Quote
Sep 12, 2003, 09:33 AM
 
Originally posted by WJMoore:
Oh and while we're offering solutions this little awk script would probably have done it
And if you don't really need the space (just the comma), this will do:

tr '\n' ',' < numbers.txt > series.txt

But certainly search and replace in most any text editor would be the more natural choice for non-Unix-heads.
     
Senior User
Join Date: Nov 2001
Location: State of Denial
Status: Offline
Reply With Quote
Sep 12, 2003, 08:27 PM
 
[Wevah setPostCount:[Wevah postCount] + 1];
     
   
Thread Tools
Forum Links
Forum 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 On
Top
Privacy Policy
All times are GMT -5. The time now is 09:39 AM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2