[Tutor] edit JSON or file in real time

dn PyTutor at DancesWithMice.info
Wed Sep 29 14:40:17 EDT 2021


On 30/09/2021 04.59, Julius Hamilton wrote:
> Hey,
> 
> I would like to edit some data - essentially, a 2d array, a spreadsheet of
> rows and columns - in a live Python shell.
> 
> I can imagine preferring that the file will remain in a tab-delimited .txt
> file, because it's very readable and easy to pass between different
> applications and so on.
> 
> However, I also would like a smooth, convenient way to load that data into
> Python in a data type easy to work with in Python, i.e. lists.
> 
> I also would like to make sure that if I edit something in that data
> structure it is saved immediately to the corresponding file. I wouldn't
> want to make an edit to an entry in the data in the live shell and somehow
> lose my progress because it wasn't written to the file.
> 
> However, I don't want to explicitly execute a "write list back to file"
> command every time a change a value in the list.
> 
> I would rather find some simple mode or mechanism where Python knows the
> list I am editing corresponds to a file, and it understands the
> correspondence. I.e., list(0) is the first entry in the tab-delimited file.
> 
> Is there any way that I could edit a list's value and it would
> automatically write to the file? Do I need to create my own object with its
> own methods, rather than the native Python list?


https://duckduckgo.com/?t=ffab&q=spreadsheet+python&atb=v269-1&ia=web

Includes libraries which will facilitate spreadsheet I/O, and Python
versions of spreadsheet software.
-- 
Regards,
=dn


More information about the Tutor mailing list