This site uses different types of cookies, including analytics and functional cookies (its own and from other sites). To change your cookie settings or find out more, click here. If you continue browsing our website, you accept these cookies.
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.
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.
@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.