Python Forum
Python script that deletes symbols in plain text - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Python script that deletes symbols in plain text (/thread-40676.html)



Python script that deletes symbols in plain text - nzcan - Sep-05-2023

I need a python script that deletes all symbols in a plain text file.
For example, I want that all 'd', all 'f' and all '0' (zeros) in a plain text file to be deleted and not replaced by other symbols.

Is open() good for this task or I should use something else?

Thanks i advance!


RE: Python script that deletes symbols in plain text - deanhystad - Sep-05-2023

You cannot delete things from a file. You can read a file and write a new file that has the contents of the old sans the unwanted symbols.

There are tools that do this kind of thing. What operating system are you using.


RE: Python script that deletes symbols in plain text - nzcan - Sep-05-2023

(Sep-05-2023, 03:52 PM)deanhystad Wrote: What operating system are you using

Linux


RE: Python script that deletes symbols in plain text - deanhystad - Sep-05-2023

Link to stackoverflow post where sed is used to remove strings from a file.
https://stackoverflow.com/questions/5998454/remove-occurrences-of-string-in-text-file