Doubt with files
Peter Pearson
pkpearson at nowhere.invalid
Tue Feb 14 12:44:18 EST 2017
More information about the Python-list mailing list
Tue Feb 14 12:44:18 EST 2017
- Previous message (by thread): Doubt with files
- Next message (by thread): WANT: bad code in python (for refactoring example)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Tue, 14 Feb 2017 09:13:48 -0800 (PST), José Manuel Suárez Sierra wrote:
> hello,
> im trying to read a rtf or txt file with this python script:
>
> with open(dirFichero,'r') as reader:
> for line in reader:
> print line
>
> the problem is that shown is : [suppressing blank lines]
>
> {\rtf1\ansi\ansicpg1252\cocoartf1504\cocoasubrtf810
> {\fonttbl\f0\fswiss\fcharset0 Helvetica;}
> {\colortbl;\red255\green255\blue255;}
> {\*\expandedcolortbl;;}
> \paperw11900\paperh16840\margl1440\margr1440\vieww10800\viewh8400\viewkind0
> \pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx [snip]
> \f0\fs24 \cf0 1l2m,1svo,1lme}
>
> INSTEAD of:
> 1l2m,1svo,1lme
>
> How could I fix it?
An RTF file *is* a text file, with formatting information inserted as
text strings. Your program is reading and printing an RTF file. If
all you want is the part of the file's content that will be visible
when it has been rendered into graphics, you'll need to convert the file
from RTF to "plain" text at some point. I'd do that with LibreOffice.
Alternativey, I see that there's a PyRTF package that might do what
you want from within your Python program.
--
To email me, substitute nowhere->runbox, invalid->com.
- Previous message (by thread): Doubt with files
- Next message (by thread): WANT: bad code in python (for refactoring example)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list