Icon

kn_​example_​python_​excel_​read_​password_​protected_​file

use python library msoffcrypto to decrypt excel file and read it back into KNIME

use python library msoffcrypto to decrypt excel file and read it back into KNIME




pip install msoffcrypto-toolhttps://pypi.org/project/msoffcrypto-tool/ import msoffcryptoimport pandas as pdv_encrypted_file = flow_variables['v_path_excel_file_source']v_decrypted_file = flow_variables['v_path_excel_file_target']file = msoffcrypto.OfficeFile(open(v_encrypted_file, "rb"))# Use passwordfile.load_key(password="password123")# Use private key# file.load_key(private_key=open("priv.pem", "rb"))# Use intermediate key (secretKey)#file.load_key(secret_key=binascii.unhexlify("AE8C36E68B4BB9EA46E5544A5FDB6693875B2FDE1507CBC65C8BCF99E25C2562"))file.decrypt(open(v_decrypted_file, "wb"))output_table = pd.DataFrame( { "path" : [v_decrypted_file] } ) use python library msoffcrypto to decrypt excel file and read it back into KNIME v_path_excel_file_sourcedecrypt excel sheetv_path_excel_file_targetv_sourcev_targetv_sourcev_targetnot able to readtest_file_with_password123_source.xlsxnow able to readtest_file_with_password123_target.xlsxthe structure is still protecteddelete target to be sure collect meta data Java EditVariable (simple) Python Source Java EditVariable (simple) Table Creator ConstantValue Column ConstantValue Column String to URI String to URI Excel Reader (XLS) Excel Reader (XLS) Delete Files pip install msoffcrypto-toolhttps://pypi.org/project/msoffcrypto-tool/ import msoffcryptoimport pandas as pdv_encrypted_file = flow_variables['v_path_excel_file_source']v_decrypted_file = flow_variables['v_path_excel_file_target']file = msoffcrypto.OfficeFile(open(v_encrypted_file, "rb"))# Use passwordfile.load_key(password="password123")# Use private key# file.load_key(private_key=open("priv.pem", "rb"))# Use intermediate key (secretKey)#file.load_key(secret_key=binascii.unhexlify("AE8C36E68B4BB9EA46E5544A5FDB6693875B2FDE1507CBC65C8BCF99E25C2562"))file.decrypt(open(v_decrypted_file, "wb"))output_table = pd.DataFrame( { "path" : [v_decrypted_file] } ) use python library msoffcrypto to decrypt excel file and read it back into KNIME v_path_excel_file_sourcedecrypt excel sheetv_path_excel_file_targetv_sourcev_targetv_sourcev_targetnot able to readtest_file_with_password123_source.xlsxnow able to readtest_file_with_password123_target.xlsxthe structure is still protecteddelete target to be surecollect meta data Java EditVariable (simple) Python Source Java EditVariable (simple) Table Creator ConstantValue Column ConstantValue Column String to URI String to URI Excel Reader (XLS) Excel Reader (XLS) Delete Files

Nodes

Extensions

Links