 |
 |
Turn list of numbers into a series of numbers ?
|
 |
|
 |
|
Mac Elite
Join Date: May 2002
Location: Los Angeles, CA.
Status:
Offline
|
|
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
|
|
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
|
|
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
|
|
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.
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: May 2002
Location: Los Angeles, CA.
Status:
Offline
|
|
|
|
|
|
| |
|
|
|
 |
|
 |
|
Professional Poster
Join Date: Oct 2001
Location: London
Status:
Offline
|
|
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
|
|
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
|
|
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
|
|
|
|
|
[Wevah setPostCount:[Wevah postCount] + 1];
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|