You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@flink.apache.org by Josh Lemer <jo...@gmail.com> on 2018/04/06 15:46:14 UTC

Get get file name when reading from files? Or assign timestamps from file creation time?

Hey there, is it possible to somehow read the filename of elements that are
read from `env.readFile`? In our case, the date of creation is encoded in
the file name.

Otherwise, maybe it is possible to assign timestamps somehow by the file's
creation time directly?

Thanks!

Re: Get get file name when reading from files? Or assign timestamps from file creation time?

Posted by Fabian Hueske <fh...@gmail.com>.
Hi Josh,

FileInputFormat stores the currently read FileInputSplit in a protected
variable FileInputFormat.currentSplit.
You can override your FileInputFormat and access the path of the read file
from the FileInputSplit in the method that emits the records from the
format.

Best,
Fabian


2018-04-06 17:46 GMT+02:00 Josh Lemer <jo...@gmail.com>:

> Hey there, is it possible to somehow read the filename of elements that
> are read from `env.readFile`? In our case, the date of creation is encoded
> in the file name.
>
> Otherwise, maybe it is possible to assign timestamps somehow by the file's
> creation time directly?
>
> Thanks!
>