Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

When I left you, I was but the pupil. Now, I am the master. -- Darth Vader


devel / comp.lang.python / Re: Extract lines from file, add to new files

SubjectAuthor
o Re: Extract lines from file, add to new filesThomas Passin

1
Re: Extract lines from file, add to new files

<mailman.30.1706673153.3227.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=24983&group=comp.lang.python#24983

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!fu-berlin.de!uni-berlin.de!not-for-mail
From: lis...@tompassin.net (Thomas Passin)
Newsgroups: comp.lang.python
Subject: Re: Extract lines from file, add to new files
Date: Tue, 30 Jan 2024 22:36:49 -0500
Lines: 55
Message-ID: <mailman.30.1706673153.3227.python-list@python.org>
References: <c9cf741b-9781-8dd6-96df-d270d0ac2@appl-ecosys.com>
<2a5eef2d-3d66-8cea-64eb-602ea5aff946@appl-ecosys.com>
<f1784a5b-662a-47fc-ada0-cc09ea2cfc24@tompassin.net>
<9028bd96-dbc8-fbc1-8584-a965ef7def5d@appl-ecosys.com>
<5cea1ab2-1848-41bd-8e5b-323fe55ba8c9@tompassin.net>
<478e3bbe-db95-9533-595b-7a19a5e2cf@appl-ecosys.com>
<e0c1c61d-2941-452a-8977-ef5c5bfb8bdb@tompassin.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de LHfp+S6ofbj1BanxBaUCsg2r3wtgvSY1FTN1jNj2LXOw==
Cancel-Lock: sha1:aVzfQHFIsWp2hB0Q5tbLdfoq92s= sha256:g7bOe4RmrF4ZdnDXImniVrZ1KocsLBx1KffjL72rYHU=
Return-Path: <list1@tompassin.net>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=tompassin.net header.i=@tompassin.net header.b=OIRk7Lpp;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.003
X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'file?': 0.05; 'modules':
0.07; 'subject:add': 0.07; 'tab': 0.07; 'subject:files': 0.09;
'downloaded': 0.13; 'addresses.': 0.16; 'anyway.': 0.16; 'bash':
0.16; 'batch': 0.16; 'complexity.': 0.16; 'else?': 0.16;
'explaining': 0.16; 'pipe': 0.16; 'received:10.0.0': 0.16;
'received:64.90': 0.16; 'received:64.90.62': 0.16;
'received:64.90.62.162': 0.16; 'received:dreamhost.com': 0.16;
'script.': 0.16; 'shepard': 0.16; 'tab.': 0.16; 'these.': 0.16;
'toy': 0.16; 'wrote:': 0.16; 'python': 0.16; 'values': 0.17;
'probably': 0.17; 'addresses': 0.19; "aren't": 0.19; 'pm,': 0.19;
'tue,': 0.19; 'to:addr:python-list': 0.20; 'input': 0.21; "i've":
0.22; 'subject:file': 0.22; "i'd": 0.24; 'help.': 0.25; 'else':
0.27; 'header:User-Agent:1': 0.30; 'program': 0.31; 'collected':
0.32; 'do.': 0.32; 'python-list': 0.32; 'received:10.0': 0.32;
'received:mailchannels.net': 0.32;
'received:relay.mailchannels.net': 0.32; 'split': 0.32; 'but':
0.32; "i'm": 0.33; 'script': 0.33; 'header:In-Reply-To:1': 0.34;
'one.': 0.35; 'files': 0.36; 'pdf': 0.36; 'those': 0.36;
'subject:from': 0.37; 'using': 0.37; 'file': 0.38; 'single': 0.39;
'text': 0.39; 'enough': 0.39; 'list': 0.39; 'use': 0.39;
'attachments.': 0.39; 'block': 0.39; 'rest': 0.39; 'still': 0.40;
'program.': 0.40; 'learn': 0.40; 'something': 0.40; 'want': 0.40;
'should': 0.40; 'search': 0.61; 'today': 0.61; 'me.': 0.62;
'email': 0.63; 'send': 0.63; 'providing': 0.63; 'top': 0.65;
'years': 0.65; 'let': 0.66; 'decided': 0.67; 'header:Received:6':
0.67; 'received:64': 0.67; 'name,': 0.75; "people's": 0.84;
'personalized': 0.84; 'recipients.': 0.84
X-Sender-Id: dreamhost|x-authsender|tpassin@tompassin.net
ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1706672211; a=rsa-sha256;
cv=none;
b=eRT1t4ywb5Px+vVtx4iSVA6v5osdCbRU3S56PdKhA4gL6SzFDbzlSjqOJs8laLuGUKlbz2
e4yC6yVCfLTHGRZvwlcEhMO+W2OmbJUr8u2uMcnh0mIz0SY83enPYW6zfMxpQiR0UNe6q4
xkFZYsV/X05+kMSiMzoPyezkp/WsI2n7cfdsvGQaftA/qtwjNZkmPiPA0eJ2EPYg/4KgjP
xeoXIYYFlnCM+zgWoAr1zrrBDkuP6i/lL9VIml7Zn9+9+C/sFZL131rPH4Y9z0t8lt939i
I2gzdGdLIJsYqXRMvNgLukfhN5gM3vA5Y5m1qmlQHfroLRd/vKXJ8CiGT3oWfw==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed;
d=mailchannels.net; s=arc-2022; t=1706672211;
h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
to:to:cc:mime-version:mime-version:content-type:content-type:
content-transfer-encoding:content-transfer-encoding:
in-reply-to:in-reply-to:references:references:dkim-signature;
bh=4ZpCcaYqNqCECbESfy/HYagI/dI8Yg6CgzdDtAk5cmc=;
b=PPP3vXNv8fZkjELccHnCAPVWAllyaYj/J3mcAH+rxzWJu9QjwPwNP7StP1vA3meFV38ILv
vK3kmAD134d3EWnExgIv/PhfdsMghk5ui7WHCQKxhLnwbYSROAXtKH1f6hkoK4Ug12UWsz
O0yuCKsGjfiYVgnS/5suAz60egwtBdt7MNJZWOxc16iztHZmJN1RnvAWXi2KShTIkfcnaW
MNoze6Ck7aDrev3DcnAJFjeur52M75xnNwIHTXlkmsKLDojjTHzWvpaFxlIaytOTeKKjhs
0oh2FCz0H1T4OGABC332YdqmsjGlV8Nu9jIoN1m2DM+mRPUqnIJsAuoFZcNGnw==
ARC-Authentication-Results: i=1; rspamd-6bdc45795d-zwd2d;
auth=pass smtp.auth=dreamhost smtp.mailfrom=list1@tompassin.net
X-Sender-Id: dreamhost|x-authsender|tpassin@tompassin.net
X-MC-Relay: Neutral
X-MailChannels-SenderId: dreamhost|x-authsender|tpassin@tompassin.net
X-MailChannels-Auth-Id: dreamhost
X-Trouble-Suffer: 70ae39074de1d793_1706672211224_2024140312
X-MC-Loop-Signature: 1706672211224:3111356819
X-MC-Ingress-Time: 1706672211224
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tompassin.net;
s=dreamhost; t=1706672210;
bh=4ZpCcaYqNqCECbESfy/HYagI/dI8Yg6CgzdDtAk5cmc=;
h=Date:From:Subject:To:Content-Type:Content-Transfer-Encoding;
b=OIRk7Lpp1TaJZBEU1mXFNXabutJ+100f5AhGwFZ/+jhTXEr+30rbeRILVtvJU9eGn
6OWxxf2ZD4lAPkoEZgUmPRLz0mS5jNy0YX8jklE6jwRlVP6mOz92A6pXt0Ds5mHzCz
UqaQkTTrEAiTkcwS+4zbuowF2K/96jeflbj8nWX74T7LNWmF+N18HakV49fpN7atCK
30+WIeMcdSRIBKkzuVz9LnP100Hd9akEfEHwbL+FZ36ja2pqiggBHzW2vbgA9hXBLU
w+VC5LZkkCSEOEcrcLHKapzbn8ZuaZiYuo5GfwQYkJmZwbCb9mbXHV7HWU4yklI+2t
8sgkej1MHdV2g==
User-Agent: Mozilla Thunderbird
Content-Language: en-US
In-Reply-To: <478e3bbe-db95-9533-595b-7a19a5e2cf@appl-ecosys.com>
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <e0c1c61d-2941-452a-8977-ef5c5bfb8bdb@tompassin.net>
X-Mailman-Original-References: <c9cf741b-9781-8dd6-96df-d270d0ac2@appl-ecosys.com>
<2a5eef2d-3d66-8cea-64eb-602ea5aff946@appl-ecosys.com>
<f1784a5b-662a-47fc-ada0-cc09ea2cfc24@tompassin.net>
<9028bd96-dbc8-fbc1-8584-a965ef7def5d@appl-ecosys.com>
<5cea1ab2-1848-41bd-8e5b-323fe55ba8c9@tompassin.net>
<478e3bbe-db95-9533-595b-7a19a5e2cf@appl-ecosys.com>
 by: Thomas Passin - Wed, 31 Jan 2024 03:36 UTC

On 1/30/2024 12:21 PM, Rich Shepard via Python-list wrote:
> On Tue, 30 Jan 2024, Thomas Passin via Python-list wrote:
>
>> Fine, my toy example will still be applicable. But, you know, you haven't
>> told us enough to give you help. Do you want to replace text from values
>> in a file? That's been covered. Do you want to send the messages using
>> those libraries? You haven't said what you don't know how to do.
>> Something
>> else? What is it that you want to do that you don't know how?
>
> Thomas,
>
> For 30 years I've used a bash script using mailx to send messages to a list
> of recipients. They have no salutation to personalize each one. Since I
> want
> to add that personalized salutation I decided to write a python script to
> replace the bash script.
>
> I have collected 11 docs explaining the smtplib and email modules and
> providing example scripts to apply them to send multiple individual
> messages
> with salutations and attachments.

If I had a script that's been working for 30 years, I'd probably just
use Python to do the personalizing and let the rest of the bash script
do the rest, like it always has. The Python program would pipe or send
the personalized messages to the rest of the bash program. Something in
that ballpark, anyway.

> Today I'm going to be reading these. They each recommend using .csv input
> files for names and addresses. My first search is learning whether I can
> write a single .csv file such as:
> "name1","address1"
> "mane2","address2"
> which I believe will work; and by inserting at the top of the message block
> Hi, {yourname}
> the name in the .csv file will replace the bracketed place holder
If the file contents are going to be people's names and email addresses,
I would just tab separate them and split each line on the tab. Names
aren't going to include tabs so that would be safe. Email addresses
might theoretically include a tab inside a quoted name but that would be
extremely obscure and unlikely. No need for CSV, it would just add
complexity.

data = f.readlines()
for d in data:
name, addr = line.split('\t') if line.strip() else ('', '')

> Still much to learn and the batch of downloaded PDF files should educate
> me.
>
> Regards,
>
> Rich

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor