Re: Keeping a list of records with named fields that can be updated

2022-12-19 Thread songbird
Peter Otten wrote: ... > I recommend that you use a dataclass /instead/ of a namedtuple, not > both. However, for a dataclass with the same fields in the same order as > in your namedtuple the conversion is trivial: > > Create compatible namedtuple and dataclass types: > > >>> NTRow = namedtuple("N

Re: Keeping a list of records with named fields that can be updated

2022-12-19 Thread Peter Otten
On 18/12/2022 16:44, songbird wrote: Peter Otten wrote: ... While I think what you need is a database instead of the collection of csv files the way to alter namedtuples is to create a new one: from collections import namedtuple Row = namedtuple("Row", "foo bar baz") row = Row(1, 2, 3) row._r

Re: Keeping a list of records with named fields that can be updated

2022-12-19 Thread Peter Otten
On 17/12/2022 20:45, Albert-Jan Roskam wrote: On Dec 15, 2022 10:21, Peter Otten <__pete...@web.de> wrote: >>> from collections import namedtuple >>> Row = namedtuple("Row", "foo bar baz") >>> row = Row(1, 2, 3) >>> row._replace(bar=42) Row(foo=1, bar=42, baz=3)

Re: Keeping a list of records with named fields that can be updated

2022-12-18 Thread songbird
Peter Otten wrote: ... > While I think what you need is a database instead of the collection of > csv files the way to alter namedtuples is to create a new one: > > >>> from collections import namedtuple > >>> Row = namedtuple("Row", "foo bar baz") > >>> row = Row(1, 2, 3) > >>> row._replace(bar=4

Re: Keeping a list of records with named fields that can be updated

2022-12-17 Thread Albert-Jan Roskam
On Dec 15, 2022 10:21, Peter Otten <__pete...@web.de> wrote: >>> from collections import namedtuple >>> Row = namedtuple("Row", "foo bar baz") >>> row = Row(1, 2, 3) >>> row._replace(bar=42) Row(foo=1, bar=42, baz=3) Ahh, I always thought these are undocumen

Re: Keeping a list of records with named fields that can be updated

2022-12-15 Thread songbird
Peter Otten wrote: > > While I think what you need is a database instead of the collection of > csv files the way to alter namedtuples is to create a new one: the files are coming from the web site that stores the accounts. i already have manually created files from many years ago with some of

Re: Keeping a list of records with named fields that can be updated

2022-12-15 Thread Weatherby,Gerard
, 2022 at 10:38 PM To: python-list@python.org Subject: Keeping a list of records with named fields that can be updated *** Attention: This is an external email. Use caution responding, opening attachments or clicking on links. *** I'm relatively new to python but not new to programming in ge

Re: Keeping a list of records with named fields that can be updated

2022-12-15 Thread Peter Otten
On 14/12/2022 19:50, songbird wrote: I'm relatively new to python but not new to programming in general. The program domain is accounting and keeping track of stock trades and other related information (dates, cash accounts, interest, dividends, transfers of funds, etc.) Assume that

Re: Keeping a list of records with named fields that can be updated

2022-12-14 Thread Thomas Passin
Dictionaries and sets are your friends here. On 12/14/2022 1:50 PM, songbird wrote: I'm relatively new to python but not new to programming in general. The program domain is accounting and keeping track of stock trades and other related information (dates, cash accounts, interest, divid

Keeping a list of records with named fields that can be updated

2022-12-14 Thread songbird
I'm relatively new to python but not new to programming in general. The program domain is accounting and keeping track of stock trades and other related information (dates, cash accounts, interest, dividends, transfers of funds, etc.) Assume that all data is CSV format. There are multi