open text file

jak nospam at please.ty
Fri Jun 24 10:03:08 EDT 2022


Il 24/06/2022 15:44, jak ha scritto:
> Il 24/06/2022 15:10, simone zambonardi ha scritto:
>> Good morning, I need to read a text file. How come when I open it 
>> (running the script) it says this? The text file is type RFT
>>
>> {\rtf1\ansi\ansicpg1252\cocoartf2636
>> \cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fswiss\fcharset0 
>> Helvetica;}
>> {\colortbl;\red255\green255\blue255;}
>> {\*\expandedcolortbl;;}
>> \paperw11900\paperh16840\margl1440\margr1440\vieww11520\viewh8400\viewkind0 
>>
>> \pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\pardirnatural\partightenfactor0 
>>
>>
>> \f0\fs24 \cf0
>>
>> But even with in .txt it gives me this long string. I think it is a 
>> formatting problem .
>> thank you
> 
> 
> I don't see the script you are talking about but it is normal to find
> those strings inside a file of type '.rtf'. RTF documents are not simple
> text documents (https://en.wikipedia.org/wiki/Rich_Text_Format) so if
> you want to extract the text contained in these documents you will need
> to use a library that can do this
> (eg: https://pypi.org/project/striprtf/)
> ...or write a parser yourself.
P.S.
renaming the file extension does not change its content but it is useful
for the system to select the app that knows how to manage it



More information about the Python-list mailing list