Hello all together,
we do have another question:
in our workflow we read a csv-file with the file-reader-node and update a database table with this file. After updating the database table we write the the csv-file to an archiv-folder.
Is there a possibilitiy to append the current date to the name of the csv-file in the csv-writer-node?
Thanks for help,
I usually use a 3 nodes to do this:
Table Creator: Set file path
// Your custom imports:
// Enter your code here:
String date = "";
Date dt = new Date();
SimpleDateFormat df = new SimpleDateFormat("yyyMMdd");
date = df.format(dt);
out_Path =(c_Path + date + ".csv");
Table Row to Variable: Allows the filename to date to be used as a flow variable.
You just need to set the filename flow variable in the CSV writer node.
Hope this helps
thanks for your answer!
The java snippet node gives an error message to me:
"WARN Java Snippet 4:55 Compile with errors:
Error: Out_Path cannot be resolved to a variable
Error: C_Path cannot be resolved to a variable"
C_Path is the name of the variable in the table creator node. The variable contains the path and the name of our csv-file without ".csv".
Can you help with this error?
You can also generate the current date with a Time Generator (1 Row and the option use Execution time)
Than cross Join the 1 row to your complete data table and convert it into a string with the date to string node.
I have attached a workflow that solves your problem.
it worked!!! The error message in the java snippet is resolved.
I had to change the name of the new variable with path, name and date into a name without out_. Furhtermore a definition of the variable as string was necessary. With this we could define the java snippet output-variable out_PathNameDate:
String PathNameDate = "";
PathNameDate = (c_C_Path + date +".csv");
out_PathNameDate = PathNameDate;
Thank you very much
Hi Iris, so you know if the Time Generator module going to be updated to non-legacy? It's a useful module and I'd like the date & time type to be updated so I don't have to cast it
I’m unsure how to open this file type using KNIME…is it not a regular workflow?
@dg-clarkston and welcome to the forum.
This workflow was a bit old - and the user above had just zipped up the workflow folder in his workspace, as opposed to exporting it. Here’s an exported workflow for you:
Date.knwf (19.7 KB)
@ScottF! I had not encountered the zip files but imported it directly after extraction and it worked fine.
Thank you so much for this. I regularly export a planner I have in excel to csv to feed into google calendar and was able to use this and just replaced the table reader for the data with my excel reader and column filter combo. So useful!!
Nice! Glad you were able to find what you needed. Old threads are still useful sometimes!
(And welcome to the KNIME forum!)
This seems to be a popular topic
having the current date or time in a file name.
@prareddy and welcome to the forum. I moved your post to a separate topic since you replied to one that was a few years old.
Can you take a look at this example from the KNIME Hub? I think it’s pretty close to what you need.