Adding timestamp to output CSV file
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi,
In my workflow I get data from a database and also get a timestamp value from another database table append the timestamp field to the main dataset, then I use output data tool to generate a CSV file with the timestamp(I use Take File/Table Name from Filed option in the output file). Everything works fine as long as the output has at least one record, but there are some cases that the output has no record ( just the header row) and I still need to generate CSV with timestamp. When there is no record in the main dataset of course append tool doesn't append the timestamp field, but in such scenarios I won't get any output because output data tool looks for the timestamp filed to name the output file. Any suggestions how we can resolve this?
thanks,
Solved! Go to Solution.
- Labels:
- Output
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
@HA,
I am attaching a sample (test) workflow that accomplishes the feat of producing a "No Record" output that can have a timestamp.
- A text input tool is used to handcraft a "No Record" output
- A Formula tool is used to create a timestamp
- A Union tool is used to combine all sets of data
- A Count Records tool is used to count the incoming data records (0, 1 or many)
- An Append Fields tool is used to put the count onto all records
- A Filter Tool is used to either DELETE the No Records when the count is 1 or more or to keep the No Records data when the count = 0
(contains([Field1],'no data') AND [Count] ==0) OR (!contains([Field1],'no data') AND [Count] !=0)
Now you can output the data to your CSV format and get No Record when you have no data.
Cheers,
Mark
Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi ,
Thank you for your reply. I use version 10 and I couldn't open your file. Would it be possible to save your file as version 10?
Thank you,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Sent from my iPhone
Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Thank you, but I have difficulty using your conversion tool. If you could just paste the screen snapshot so I know how to arranged the tools I can figure out the details. I really appreciate your help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
attached is a workflow that you can open.
Cheers,
Mark
Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
@MarqueeCrew. thank you for the solution. I use your solution in my workflow but there is a slight issue with this solution. When there is no record It generates the header row ( which I want) but it also adds the delimiters (in this case | ) to the second row. something like
header row ------ > A|B|C|D
First record ------> ||||
I don't need the first records ( delimiters) to be part of the output file. I don't think there is a way Alteryx to avoid this so now I'm thinking to remove this unwanted row in a batch file (I tiger a batch file after file generation for doing some file transfer etc. so I can add file cleanup to the batch file)
