Merge branch 'main' of https://gitea.casaparma.dscloud.me/Miguel/DBsExcel_con_UDT
This commit is contained in:
commit
b287417c22
36
CopyPaste.py
36
CopyPaste.py
|
@ -1,36 +0,0 @@
|
||||||
import os
|
|
||||||
import subprocess
|
|
||||||
import tkinter as tk
|
|
||||||
from tkinter import filedialog
|
|
||||||
|
|
||||||
def select_file():
|
|
||||||
"""
|
|
||||||
Opens a file dialog to select a .db file and returns the selected file path.
|
|
||||||
"""
|
|
||||||
root = tk.Tk()
|
|
||||||
root.withdraw() # Use to hide the tkinter root window
|
|
||||||
|
|
||||||
# Open file dialog and return the selected file path
|
|
||||||
file_path = filedialog.askopenfilename(
|
|
||||||
title="Select a .db file",
|
|
||||||
filetypes=(("DB files", "*.db"), ("All files", "*.*"))
|
|
||||||
)
|
|
||||||
return file_path
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
file_path = select_file()
|
|
||||||
if file_path: # Proceed only if a file was selected
|
|
||||||
with open(file_path, "r", encoding="utf-8-sig") as file:
|
|
||||||
lines = file.readlines()
|
|
||||||
|
|
||||||
udt_json = parse_udts(lines)
|
|
||||||
# Assume processing and file generation happens here, e.g., creating `output.txt`
|
|
||||||
output_file_path = os.path.join(os.path.dirname(file_path), "output.txt")
|
|
||||||
# Save or manipulate output files as needed
|
|
||||||
|
|
||||||
# Open the directory containing the new file in Explorer
|
|
||||||
open_file_explorer(os.path.dirname(output_file_path))
|
|
||||||
else:
|
|
||||||
print("No file was selected.")
|
|
Loading…
Reference in New Issue