Need Help Adjusting Lines
Moderators: AmigoJack, bbadmin, helios, MudGuard
Need Help Adjusting Lines
I have a mailing list with over 500 entries which I need help with. My list is currently configured like this:
---------------------
name@email.com
firstname
name2@email2.com
firstname2
---------------------
I first need to check for duplicate email addresses in the file, so I would like to know if its possible to remove all of the "first names" from the file and all spaces so the end result looks like this:
---------------------
name@email.com
name2@email2.com
---------------------
The second thing I need to figure out is to add quotes around each item and add a comma between them, so it ends up like this:
------------------------------------
"name@email.com","firstname"
"name2@email2.com","firstname2"
------------------------------------
Thanks!
---------------------
name@email.com
firstname
name2@email2.com
firstname2
---------------------
I first need to check for duplicate email addresses in the file, so I would like to know if its possible to remove all of the "first names" from the file and all spaces so the end result looks like this:
---------------------
name@email.com
name2@email2.com
---------------------
The second thing I need to figure out is to add quotes around each item and add a comma between them, so it ends up like this:
------------------------------------
"name@email.com","firstname"
"name2@email2.com","firstname2"
------------------------------------
Thanks!
- Bob Hansen
- Posts: 1516
- Joined: Sun Mar 02, 2003 8:15 pm
- Location: Salem, NH
- Contact:
Do the ------------------------------- lines really exist, or are they shown here for some type of clarity?
Do you have this?
Do you have this?
or this?---------------------
name@email.com
firstname
name2@email2.com
firstname2
---------------------
name3@email3.com
firstname3
name4@email4.com
firstname4
---------------------
name@email.com
firstname
name2@email2.com
firstname2
name3@email3.com
firstname3
name4@email4.com
firstname4
Hope this was helpful.............good luck,
Bob
Bob
The file looks like this:
Code: Select all
name@email.com
firstname
name2@email2.com
firstname2
name3@email.com
firstname3
name4@email2.com
firstname4
-
ben_josephs
- Posts: 2464
- Joined: Sun Mar 02, 2003 9:22 pm
If the "first name" lines can be identified as those not containing an '@', then to remove them:
To remove the blank lines:Find what: ^[^@]+\n
Replace with:
[X] Regular expression
If all "first name" lines are followed by exactly one blank line, then to remove the "first name" and blank lines together:Find what: \n\n
Replace with: \n
[X] Regular expression
Find what: ^[^@]+\n\n
Replace with:
[X] Regular expression
ben_josephs-
Awesome! Works perfectly. My last concern is how to setup the file, so the end result looks like this:
Before:
After:
Thanks for your help!
Awesome! Works perfectly. My last concern is how to setup the file, so the end result looks like this:
Before:
Code: Select all
email1@email1.com
firstname
email2@email2.com
firstname
email3@email3.com
firstname
After:
Code: Select all
"email1@email1.com","firstname"
"email2@email2.com","firstname"
"email3@email3.com","firstname"
-
ben_josephs
- Posts: 2464
- Joined: Sun Mar 02, 2003 9:22 pm
ben_josephs-
Perfect! You saved me a ton of time.
However, I just ran into a small issue. I have have my list of email addresses and when I sort them for duplicates, I can't see which emails are being removed in TextPad. So, I take the file and run it in SSH with this Unix command:
This shows me all the duplicate entries but what I noticed was its case sensitive, so it did not find a few entries which were entered as:
Is there any way to have find out which duplicate entries are removed when I run a "sort" in TextPad?
Thanks!
Perfect! You saved me a ton of time.
However, I just ran into a small issue. I have have my list of email addresses and when I sort them for duplicates, I can't see which emails are being removed in TextPad. So, I take the file and run it in SSH with this Unix command:
Code: Select all
uniq -d "filename"
Code: Select all
email1@email.com
Email1@Email.COM
Thanks!
-
ben_josephs
- Posts: 2464
- Joined: Sun Mar 02, 2003 9:22 pm
There isn't a way that I am aware of in TextPad to find this out.
Use
Use
Code: Select all
uniq -d -i "filename" ben_josephs-
Thanks for all your help on the past questions. I have two more quick questions for you. I need to figure out a way to take entries on my newsletter list like this:
The end result willl remove the first names and the commas with an end result looking like this:
I also need to take existing entries like this:
And have them end up like this:
Thanks!
Thanks for all your help on the past questions. I have two more quick questions for you. I need to figure out a way to take entries on my newsletter list like this:
Code: Select all
email@email.com,John
email2@email2.com,Mike
email3@email3.com,Steve
Code: Select all
email@email.com
email2@email2.com
email3@email3.com
Code: Select all
email@email.com,John
email2@email2.com,Mike
email3@email3.com,Steve
Code: Select all
"email@email.com","John"
"email2@email2.com","Mike"
"email3@email3.com","Steve"
-
ben_josephs
- Posts: 2464
- Joined: Sun Mar 02, 2003 9:22 pm
Find what: ,.*
Replace with:
[X] Regular expression
These assume you are using POSIX regular expression syntax:Find what: ([^,]+),(.*)
Replace with: "\1","\2"
[X] Regular expression
Perhaps it's time to look up "Regular Expressions" in TextPad's help, and even, maybe, to glance at Jeffrey E. F. Friedl's much-recommended book Mastering Regular Expressions (http://www.oreilly.com/catalog/regex2/).Configuration | Preferences | Editor
[X] Use POSIX regular expression syntax