Add timestamp of a read table

Hi,

the following question: I would like to add a column to a table that I have read (via File Reader) and edited with Knime, where in each row of the new column a timestamp is written, which refers to the date and time when the read file was originally created. (So the same content in each row of the new column.)
Would be great if there someone had a suggestion :slight_smile: .

Thanks a lot
Christian

You should be able to use the

to get information about a file and turn them into a constant value.

Here are some operations with files and paths - but with often deprecated nodes but maybe you can use the ideas behind the arrangements

4 Likes

Hello @Christian_Essen,

maybe looking for Constant Value Column node?

Br,
Ivan

1 Like

@mlauber71 & @ipazin : After some delay, thank you very much for your support! :slight_smile:
I don’t think I had formulated the question completely: I wanted to automatically set timestamps in the rows of a table if there are several tables or files in a folder, so that the completely merged table shows which rows were written when. My mistake :sweat_smile:.

In the meantime, I have also managed to develop a workflow for this (see below).
I have a question: I would like to upload it to public KNIME hub, i.e. make it generally accessible. What is the best way to select example files, because the ones on my computer won’t work for everyone?

Many thanks,
Christian

1 Like

Hi @Christian_Essen , if I understand correctly, you just want to capture the current timestamp at a particular stage of the workflow, correct?

I have a component that I created that retrieves the current timestamp. It returns your local time as well as utc timestamp. It also returns them as timestamps and string format (in case you want to append the timestamp to file names, column names, etc).

It returns them as variables. You can add them as column via the Constant Value Column if needed.

Here’s how the results look like:
image

And here is the source of the component: Component - Get Current Timestamp.knwf (15.7 KB)

You could download one of many files that are out there:

Or you could use the Data generator to get a simple file:

3 Likes

Hello @Christian_Essen,

why your files won’t work? If they are confidential you can create dummy ones. Check here how to create reproducible workflow examples:

Br,
Ivan

3 Likes

@bruno29a : Thank you very much for your support :slight_smile:. Unfortunately, it’s not quite what I had been looking for ("… which refers to the date and time when the read file was originally created.") :wink:

@ipazin : Thanks again for your great support :wink:.
When I said that the file does not work for everyone, I meant the fact that the file path refers to my local file system. In the meantime, however, I have learned from your post that you can then simply select “Relative to” “Current workflow” as parameters. However, I then get an “Illegal char” error message (as described in the “Shutdown problem” thread).

Hey @Christian_Essen , sorry I misunderstood. I thought you wanted to capture the current timestamp during execution, I thought you wanted to know when the file was read, kinda to track execution time or something, and also in your clarification, you mentioned “merged table shows which rows were written when”. So based on that, the idea would be to capture the current timestamp at the proper stage of the workflow, and add the captured timestamp as column with the Constant Value Column node.

If your issue is still not solved, what do you need? :slight_smile:

1 Like

Thanks for the reminder @bruno29a - I have now ticked the solution check box :nerd_face:

1 Like

Hello again @Christian_Essen,

as explained in other topic you can copy files into data folder within workflow directory and use Relative to path with Current workflow data area option to make your workflow reproducible :wink: (Added this info one more time for others who bump into this topic.)

Br,
Ivan

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.