Firstly, thanks Carl_M! I will try to ask this question with more simple code. Using tkinker-
the user is asked to select the directory and new subfolder. That works.
Then browse for an exel file that will be modified as a df and sent to the new subfolder. That sort of works (thanks to Carl), but file doesn’t go to the new subfolder. It goes to the selectPath. How can I add the path to the folder?
Used ‘dirs = os.path.join(path.get(), folder.get())’ to assign location, but it’s not landing there.
JavaScript
x
16
16
1
def selectPath():
2
path_ = askdirectory()
3
path.set(path_)
4
5
6
def create_subfolder():
7
print("folder_name: ", folder.get())
8
print("path_name: ", path.get())
9
dirs = os.path.join(path.get(), folder.get())
10
11
def openFile():
12
filename = filedialog.askopenfilename(initialdir = r'L:folderMy_file', filetypes=[("Excel Files", "*.xlsx")])
13
os.startfile(filename)
14
df = pd.read_excel(filename, sheet_name = 'Order Details')
15
df.to_excel(((dirs) + 'Intelliscan.xlsx'),index=False)
16
Advertisement
Answer
Try
JavaScript
1
7
1
def openFile():
2
filename = filedialog.askopenfilename(initialdir = r'L:folderMy_file', filetypes=[("Excel Files", "*.xlsx")])
3
os.startfile(filename)
4
df = pd.read_excel(filename, sheet_name = 'Order Details')
5
destination = os.path.join(path.get(), folder.get(),'Intelliscan.xlsx')
6
df.to_excel(destination,index=False)
7