ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
It reads the files as text only (in Windows there is a difference between "read" and "binary read"). Different formats such as html, pdf, doc are then achieved by creating the file with some structure that is known. For example html is plaintext where the content is put inside different kinds of tags, and the rendering application reads the tags, interprets them and displays content based on that. So you can read html files (for example, or any other files) in Python, but it will just read the contents and you will have to deal with the content type yourself - tell Python how and what to read and where, and how to represent it. There is no builtin "read pdf" or "read doc" thing, there could be a "library" or something for that if somebody had made it, but I'm not sure.
If it was that easy to read pdf/doc/... and even write, why would we pay for MS Office and such?
So you can read html files (for example, or any other files) in Python, but it will just read the contents and you will have to deal with the content type yourself - tell Python how and what to read and where, and how to represent it.
I need
Quote:
For Word document on windows, you can use COM object and the win32 module. See a sample here.
For PDF, you can use reportlabs third party library
?
I don't understand if the two ways are just one, or differ one from the other.
I don't need to change the files,or manipulate the strings in them, just read and extract some text.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.