Advent of Code is now back for a limited time only! Complete as many challenges as you can to earn those badges you may have missed in December. Learn more about how to participate here!
Start Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.

Dynamically write output to most recent Excel

agrawaluk
8 - Asteroid

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?

2 REPLIES 2
abe_ibanez
9 - Comet

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. 

agrawaluk
8 - Asteroid

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. 

Labels
Top Solution Authors