Add MedicusWithClaude project - DB exploration scripts and notes
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
34
MedicusWithClaude/analyze_rtf.py
Normal file
34
MedicusWithClaude/analyze_rtf.py
Normal file
@@ -0,0 +1,34 @@
|
||||
import fdb, re
|
||||
|
||||
conn = fdb.connect(
|
||||
dsn=r'localhost:c:\medicus 3\data\medicus.fdb',
|
||||
user='SYSDBA', password='masterkey', charset='win1250'
|
||||
)
|
||||
cur = conn.cursor()
|
||||
cur.execute('SELECT DEKURS FROM DEKURS WHERE ID=243082')
|
||||
text = cur.fetchone()[0]
|
||||
text = text.read() if hasattr(text, 'read') else text
|
||||
text = text.decode('windows-1250', errors='replace') if isinstance(text, bytes) else text
|
||||
|
||||
# colortbl
|
||||
ct = re.search(r'\\colortbl[^}]+\}', text)
|
||||
if ct: print('COLORTBL:', ct.group(0))
|
||||
|
||||
# stylesheet
|
||||
ss = re.search(r'\\stylesheet\{.+?\}(?=\n)', text, re.DOTALL)
|
||||
if ss: print('\nSTYLESHEET:', ss.group(0)[:600])
|
||||
|
||||
# Najdi různé styly použité v textu
|
||||
print('\n--- Použité RTF tagy (unikátní) ---')
|
||||
tags = re.findall(r'\\[a-z]+\d*', text)
|
||||
from collections import Counter
|
||||
for tag, count in Counter(tags).most_common(40):
|
||||
print(f" {tag:<20} {count}x")
|
||||
|
||||
# Ukázka tabulky
|
||||
tbl_start = text.find(r'\trowd')
|
||||
if tbl_start > 0:
|
||||
print('\n--- Začátek tabulky ---')
|
||||
print(text[tbl_start:tbl_start+300])
|
||||
|
||||
conn.close()
|
||||
Reference in New Issue
Block a user