Re: Extract lines from file, add to new files

2024-01-11 Thread Grizzy Adams via Python-list
Thursday, January 11, 2024 at 10:44, Rich Shepard via Python-list wrote: Re: Extract lines from file, add to (at least in part) >On Thu, 11 Jan 2024, MRAB via Python-list wrote: >> From the look of it: >> 1. If the line is empty, ignore it. >> 2. If the line contains "@", it's an email address.

Re: Extract lines from file, add to new files

2024-01-11 Thread dn via Python-list
On 12/01/24 12:56, Chris Angelico via Python-list wrote: On Fri, 12 Jan 2024 at 08:56, Left Right via Python-list wrote: By the way, in an attempt to golf this problem, I discovered this, which seems like a parser problem: When you jump immediately to "this is a bug", all you do is make "s

Re: Extract lines from file, add to new files

2024-01-11 Thread Chris Angelico via Python-list
On Fri, 12 Jan 2024 at 08:56, Left Right via Python-list wrote: > > By the way, in an attempt to golf this problem, I discovered this, > which seems like a parser problem: When you jump immediately to "this is a bug", all you do is make yourself look like an idiot. Unsurprisingly, this is NOT a b

Re: Extract lines from file, add to new files

2024-01-11 Thread dn via Python-list
On 12/01/24 10:33, Left Right via Python-list wrote: By the way, in an attempt to golf this problem, I discovered this, which seems like a parser problem: This is what Python tells me about its grammar: with_stmt: | 'with' '(' ','.with_item+ ','? ')' ':' block | 'with' ','.with_item+

Re: Extract lines from file, add to new files

2024-01-11 Thread Left Right via Python-list
Ah, nevermind. I need to be more careful, there isn't an "'as' star_target" after the first rule. On Thu, Jan 11, 2024 at 10:33 PM Left Right wrote: > > By the way, in an attempt to golf this problem, I discovered this, > which seems like a parser problem: > > This is what Python tells me about i

Re: Extract lines from file, add to new files

2024-01-11 Thread Left Right via Python-list
By the way, in an attempt to golf this problem, I discovered this, which seems like a parser problem: This is what Python tells me about its grammar: with_stmt: | 'with' '(' ','.with_item+ ','? ')' ':' block | 'with' ','.with_item+ ':' [TYPE_COMMENT] block | ASYNC 'with' '(' ','.with_

Re: Extract lines from file, add to new files

2024-01-11 Thread Thomas Passin via Python-list
On 1/11/2024 1:27 PM, MRAB via Python-list wrote: On 2024-01-11 18:08, Rich Shepard via Python-list wrote: It's been several years since I've needed to write a python script so I'm asking for advice to get me started with a brief script to separate names and email addresses in one file into two

Re: Extract lines from file, add to new files

2024-01-11 Thread Mirko via Python-list
Am 11.01.24 um 20:53 schrieb Rich Shepard via Python-list: On Thu, 11 Jan 2024, Piergiorgio Sartor via Python-list wrote: Why not to use bash script for all? Piergiorgio, That's certainly a possibility, and may well be better than python for this task. Thank you, Rich awk '/@/ {print >

Re: Extract lines from file, add to new files

2024-01-11 Thread Rich Shepard via Python-list
On Thu, 11 Jan 2024, Piergiorgio Sartor via Python-list wrote: Why not to use bash script for all? Piergiorgio, That's certainly a possibility, and may well be better than python for this task. Thank you, Rich -- https://mail.python.org/mailman/listinfo/python-list

Re: Extract lines from file, add to new files

2024-01-11 Thread Piergiorgio Sartor via Python-list
On 11/01/2024 19.08, Rich Shepard wrote: It's been several years since I've needed to write a python script so I'm asking for advice to get me started with a brief script to separate names and email addresses in one file into two separate files: salutation.txt and emails.txt. An example of the i

Re: Extract lines from file, add to new files

2024-01-11 Thread Rich Shepard via Python-list
On Thu, 11 Jan 2024, Mats Wichmann via Python-list wrote: 4. Don't assume it's going to be "plain text" if the email info is harvested from external sources (like incoming emails) - you'll end up stumbling over a 誰かのユーザー from somewhere. Process as bytes, or be really careful about which encoding

Re: Extract lines from file, add to new files

2024-01-11 Thread Mats Wichmann via Python-list
On 1/11/24 11:27, MRAB via Python-list wrote: On 2024-01-11 18:08, Rich Shepard via Python-list wrote: It's been several years since I've needed to write a python script so I'm asking for advice to get me started with a brief script to separate names and email addresses in one file into two sepa

Re: Extract lines from file, add to new files

2024-01-11 Thread Rich Shepard via Python-list
On Thu, 11 Jan 2024, MRAB via Python-list wrote: From the look of it: 1. If the line is empty, ignore it. 2. If the line contains "@", it's an email address. 3. Otherwise, it's a name. MRAB, Thanks. I'll take it from here. Regards, Rich -- https://mail.python.org/mailman/listinfo/python-lis

Re: Extract lines from file, add to new files

2024-01-11 Thread MRAB via Python-list
On 2024-01-11 18:08, Rich Shepard via Python-list wrote: It's been several years since I've needed to write a python script so I'm asking for advice to get me started with a brief script to separate names and email addresses in one file into two separate files: salutation.txt and emails.txt. An

Extract lines from file, add to new files

2024-01-11 Thread Rich Shepard via Python-list
It's been several years since I've needed to write a python script so I'm asking for advice to get me started with a brief script to separate names and email addresses in one file into two separate files: salutation.txt and emails.txt. An example of the input file: Calvin cal...@example.com Hob