pyarrow.fs.FileInfo#

classpyarrow.fs.FileInfo(path,FileTypetype=FileType.Unknown,mtime=None,*,mtime_ns=None,size=None)#

Bases:_Weakrefable

FileSystem entry info.

Parameters:
pathstr

The full path to the filesystem entry.

typeFileType

The type of the filesystem entry.

mtimedatetime orfloat, defaultNone

If given, the modification time of the filesystem entry.If a float is given, it is the number of seconds since theUnix epoch.

mtime_nsint, defaultNone

If given, the modification time of the filesystem entry,in nanoseconds since the Unix epoch.mtime andmtime_ns are mutually exclusive.

sizeint, defaultNone

If given, the filesystem entry size in bytes. This should onlybe given iftype isFileType.File.

Examples

Generate a file:

>>>frompyarrowimportfs>>>local=fs.LocalFileSystem()>>>path_fs=local_path+'/pyarrow-fs-example.dat'>>>withlocal.open_output_stream(path_fs)asstream:...stream.write(b'data')4

Get FileInfo object usingget_file_info():

>>>file_info=local.get_file_info(path_fs)>>>file_info<FileInfo for '.../pyarrow-fs-example.dat': type=FileType.File, size=4>

Inspect FileInfo attributes:

>>>file_info.type<FileType.File: 2>
>>>file_info.is_fileTrue
>>>file_info.path'/.../pyarrow-fs-example.dat'
>>>file_info.base_name'pyarrow-fs-example.dat'
>>>file_info.size4
>>>file_info.extension'dat'
>>>file_info.mtimedatetime.datetime(2022, 6, 29, 7, 56, 10, 873922, tzinfo=datetime.timezone.utc)
>>>file_info.mtime_ns1656489370873922073
__init__(*args,**kwargs)#

Methods

__init__(*args, **kwargs)

Attributes

base_name

The file base name.

extension

The file extension.

is_file

mtime

The time of last modification, if available.

mtime_ns

The time of last modification, if available, expressed in nanoseconds since the Unix epoch.

path

The full file path in the filesystem.

size

The size in bytes, if available.

type

Type of the file.

base_name#

The file base name.

Component after the last directory separator.

Examples

>>>file_info=local.get_file_info(path)>>>file_info.base_name'pyarrow-fs-example.dat'
extension#

The file extension.

Examples

>>>file_info=local.get_file_info(path)>>>file_info.extension'dat'
is_file#
mtime#

The time of last modification, if available.

Returns:
mtimedatetime.datetime orNone

Examples

>>>file_info=local.get_file_info(path)>>>file_info.mtimedatetime.datetime(2022, 6, 29, 7, 56, 10, 873922, tzinfo=datetime.timezone.utc)
mtime_ns#

The time of last modification, if available, expressed in nanosecondssince the Unix epoch.

Returns:
mtime_nsint orNone

Examples

>>>file_info=local.get_file_info(path)>>>file_info.mtime_ns1656489370873922073
path#

The full file path in the filesystem.

Examples

>>>file_info=local.get_file_info(path)>>>file_info.path'/.../pyarrow-fs-example.dat'
size#

The size in bytes, if available.

Only regular files are guaranteed to have a size.

Returns:
sizeint orNone
type#

Type of the file.

The returned enum values can be the following:

  • FileType.NotFound: target does not exist

  • FileType.Unknown: target exists but its type is unknown (could be aspecial file such as a Unix socket or character device, orWindows NUL / CON / …)

  • FileType.File: target is a regular file

  • FileType.Directory: target is a regular directory

Returns:
typeFileType