I have an excel and I want alteryx to write an output to a new sheet, picking up the most recent excel in the folder everyday it is run. I have the dynamic excel file name and sheet name in a column. How to do this?
Hello,
How are you defining "most recent Excel"? Is there something in the name of the file that indicates when the version (like yyyymmdd_file_name.xlsx) or are you trying to look at the Excel file that was last updated?
I would recommend using a Python tool to extract the info from the target directory given that Python has a robust OS library.
For example, if the file name has the date in its tittle, you could use the following script within the Python tool to extract every file name in that directory:
#################################
# List all non-standard packages to be imported by your
# script here (only missing packages will be installed)
from ayx import Package
#Package.installPackages(['pandas','numpy'])
#################################
from ayx import Alteryx
import pandas as pd
#################################
from os import listdir
from os.path import isfile, join
#################################
path = Alteryx.read("#1")
#################################
files = [f for f in listdir(path.iloc[0,0]) if isfile(join(path.iloc[0,0], f))]
#################################
df = pd.DataFrame(files, columns=['files'])
#################################
Alteryx.write(df,1)
#################################
This script would take as input the path to the directory and outputs a list of all the file names.
I think I figured out my problem. I configured the output tool to write it to most recent output. I was missing ".xlsx" in my full path coming from directory tool. Thanks for your time! Really appreciate it.