From fbe9a35fdbb44055fc398c303b813ad0b68504b9 Mon Sep 17 00:00:00 2001 From: Daniel Behmer Date: Sun, 28 Aug 2022 08:41:11 -0700 Subject: Started Text File Conversion --- FBGM.py | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/FBGM.py b/FBGM.py index 99cb4bf..b269177 100644 --- a/FBGM.py +++ b/FBGM.py @@ -1,8 +1,18 @@ from ftplib import parse150 import os, sys -def txthandler(path): - f = open(path) +def txthandler(path, filename): + f = open(path, "r") + contents = f.read() + filename.write('' +'' + '' + ''+contents[0:contents.rfind('\n')]+'' + '' + '' + '' + '' +'') print(f.read()) return 0 @@ -17,17 +27,25 @@ def dochandler(path): print(f.read()) return 0 -#Attempting to pass docx file in path -path = 'C:/Users/a big fuck/Downloads/beans.docx' +#Attempting to pass txt file in path +path = 'C:/Users/a big fuck/Documents/beansandtoast.txt' extension = path[path.rfind('.')+1: len(path)] -print(extension) +filename = path[path.rfind('/')+1: path.rfind('.')] + + +if os.path.exists(filename+".html") == True: + os.remove(filename+".html") + +htmlfile = open(filename+".html", "x") + + if extension =='txt': - txthandler(path) + txthandler(path, htmlfile) elif extension == 'pdf': pdfhandler(path) -- cgit v1.2.3