Hello All,
I have a table where it has 2 columns employee Name and Department, My requirement is to create a folders based on the department and generate excel output in that folder with respect to department and employee Name.
I tried to create a folder using bat file its creating successfully, but my bat file still remains in that folder so it might be risk or junk file for end users.
How to create the folder and delete that bat folder using Alteryx version 2020.1
could some one advise on this to resolve it.
Thanks
Dinesh
python would be an easier way honestly.
pass 2 columns like the below into python tool, it will generate the folders and give them back in a dataset then you can use that for whatever in your workflow
folder_path folder_name
c:\temp A
c:\temp b
etc
from ayx import Alteryx
import os
import pandas as pd
df = Alteryx.read("#1")
def create_folder(dataframe):
created_paths = []
for index, row in dataframe.iterrows():
folder_path = row['folder_path']
file_name = row['file_name']
full_path = os.path.join(folder_path,file_name)
if not os.path.exists(full_path):
os.makedirs(full_path)
created_paths.append(full_path)
return created_paths
created_paths = create_folder(df)
created_paths_df = pd.DataFrame({'created_paths':created_paths})
Alteryx.write(created_paths_df,1)
Hi @jbravman_
I have never used Python in Alteryx, could you please share me the sample workflow so that it would be more helpful
@dineshbabu2811 - Let me know if this works :)
@Hamder83 I'm getting the below error
@dineshbabu2811 you could write your bat file to the temp drive by setting its filepath as something like:
%TEMP%/script.bat
This file would then be automatically deleted whenever the temp drive is flushed, and either way wouldn't be easily exposed to users
@dineshbabu2811 there's more information on writing to the temp directory here: https://help.alteryx.com/20231/designer/alteryx-and-temporary-files#:~:text=By%20default%2C%20the%20....
It didn't work as expected
I can able to create a folder using temp bat file, but when it comes to end user while running from gallery its not working. Also I tried to hardcorde the path of the bat file, after creating the folder bat file still exists in the folder, obviously we don't need bat file to be present. Is there way to kill itself ?