I am fairly new to python.I am currently using python scripting.My problem is,I have some txt files from which i need to extract only words(characters) and remove digits,new lines and special characters(like ----, []) and store it in a another txt file with a different name.
Please help.

Recommended Answers

All 2 Replies

Here is a mild hint:

import re

s = "Lotus 123 is an older spread-sheet, still in use though!"

# sub all characters with empty "" that are not letters
p = re.compile("[^a-z A-Z]")
s2 = p.sub("", s)

print s2  # Lotus  is an older spreadsheet still in use though

Thanks a lot ZZucker.Thanks for the Hint.It helped me a lot.I am able extract the contents.
Thanks once again.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.