Skip to content

Commit

Permalink
helper function
Browse files Browse the repository at this point in the history
  • Loading branch information
tsmonteiro committed May 8, 2024
1 parent 8883cc2 commit 9077d05
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tercen/util/helper_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,29 @@ def image_file_to_df(file_path):

return imgDf

def text_to_markdown_df(filename, txt):

mimetype = "text/markdown"
txt = txt.replace("[", "**")\
.replace("]", "**")\
.replace("\n", "\n\n")

txtBytes = txt.encode("utf-8")
checksum = hashlib.md5(txtBytes).hexdigest()

output_str = [ base64.b64encode(txtBytes) ]


outs = output_str[0].decode('utf-8')
txtDf = pd.DataFrame({
"filename":[filename],
"mimetype":[mimetype],
"checksum":[checksum],
".content":[outs]
})

return txtDf

def get_temp_filepath(ext=''):

if ext != '' and str.find(ext, '.') < 0:
Expand Down

0 comments on commit 9077d05

Please sign in to comment.