community
cancel
Showing results for 
Search instead for 
Did you mean: 

Alteryx designer Discussions

Find answers, ask questions, and share expertise about Alteryx Designer.
Upgrade Alteryx Designer in 10 Steps

Debating whether or not to upgrade to the latest version of Alteryx Designer?

LEARN MORE
SOLVED

Output only a header row?

Highlighted

Seems like it should be simple, but I'm baffled.

 

I have a need to output datasets using the Output Data tool even if those datasets are empty.

 

In other words, I have 10 datasets that I output to .csv's for further processing. This further processing demands that 10 .csv's always exist, even if a given dataset is empty. So if a dataset is empty, I only want to output the header row... no other data.

 

Problem is, if an empty dataset is passed into the Output Data tool, it appears that it will not actually write a file. And if I pass in a dataset with just an empty row, I get a file but it has the header row and an extra row of delimiters for the empty data.

 

Anyone have any ideas?

Alteryx Certified Partner

Try using a dummy input that has all the necessary fields and use a Sample tool set to "First 0 rows" before the output. It will output a file with all the fields, but 0 records.

@CharlieS - Great solution!  I learned something new too.  I originally went a longer way to solve the problem, yours was much better.

This doesn't work for me, for whatever reason.

Selecting "First 0 Rows" in the Sample Tool results in an null resultset (of course), and, again, my Output Tool refuses to output a .csv from a null resultset.

 

My solution was to use the Formula Tool to set all the fields to a string containing their column name, then unchecking the "First row has column names" in the Output Tool. That's the only way I could get an output file.

@carl_steinhilber - I was able to get both methods to work.  Did you check out the sample workflow that I attached?  It sounds like my first method did it for you?  If so, please mark it as an answer.

@OldDogNewTricks Actually, I hadn't downloaded your workflow. I was only commenting on Charlie's solution. Opening up your workflow I see that our solutions were very similar, though you did a much better job (used the Cross Tab tool to handle dynamic column names, whereas I hard-coded them) so yes, I'll mark your answer as the solution.

 

I also had a "DUH" moment. The reason my Output tool wasn't writing a file was because it's dynamic, taking the target filename from a field in the dataset. And, of course, with 0 rows there was no value for the filename field passed in. Thus, our method is the only solution that would work in this situation. Charlie's will only work if the filename is known and hardwired in the tool.

Labels