How can I edit the contents of txt file?

Hi, I want to update the value of the contents of the text file by adding integer one to the value after ',' for a specific row.

This is our progress as of now.

This is the content of trendsList.txt:
image

Expected Output (for example, first row is selected):
image

Actual Output:
image

Please I need assistance. Thanks in advance.

1 Like

same problem i am experiencing

your content of the text file is a csv table.
You can use image to change the content to a list of list, then iterate the list to modify any item.
Then convert this list back to csv table, then save to file.

Hi, do you have a sample on how to implement this?

Since you have the same ip address as @Ivan1 that is not surprising. :wink:

1 Like

Packing up your table back into a file after updating it is like living out of a suitcase.

If you are going to keep on updating counts, consider keeping the data in TinyDB, with tag = drug name and value = count.

Convert it to a file only when you need to export it.