Skip to main content

FilesClient

Methods

__init__()

download()

Download a file from Datagrok.

Parameters

NameTypeDescription
connectorstr or DataConnectionDataConnection or ID or Grok name.
pathstrPath to file in a connector

Returns

TypeDescription
Union[pd.DataFrame, bytes]If requested file is csv, returns corresponding pd.DataFrame. Otherwise returns bytes with file content.

upload()

Uploads a file to Datagrok.

Parameters

NameTypeDescription
connectorstr or DataConnectionDataConnection or ID or Grok name.
pathstrPath to file in a connector
file_pathstrPath to local file that needs to be uploaded

sync_dir()

Syncs the content of a local directory with a remote directory on a server, updating local files and metadata based on the response. This method compares the current state of the local directory with the remote directory and updates files based on their modified status or whether they have been deleted. It uses a provided connector to connect to a remote service and syncs the data, storing metadata about file versions and deletions in a .sync_meta.json file. If a file has been deleted on the server, it will also be deleted locally.

Parameters

NameTypeDescription
connectorstr or DataConnectionDataConnection or ID or Grok name.
remote_pathstrThe path on the server connection to sync with. Should be directory
dirstrThe local directory to sync. If the directory doesn't exist, it will be created.
extstr, optionalA file extension filter to limit the types of files to sync. If not specified, all files are synced.
recursiveboolWhether to sync the directory recursively, including subdirectories. If False, only files in the root of the directory are synced.
sync_meta_filestr, optionalThe name of the metadata file that stores the eTags and sync information for the files. This file is used to track the current state of the local directory and should be present for syncing to work correctly.