open text file

17 views
Skip to first unread message

simone zambonardi

unread,
Jun 24, 2022, 9:11:13 AMJun 24
to
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

jak

unread,
Jun 24, 2022, 9:44:25 AMJun 24
to
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.

jak

unread,
Jun 24, 2022, 10:03:25 AMJun 24
to
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

Reply all
Reply to author
Forward
0 new messages