File Connector
opengate_data.file_connector
opengate_data.file_connector.file_connector
FileConnectorBuilder Objects
class FileConnectorBuilder()File Connector Builder
with_organization_name
def with_organization_name(organization_name: str) -> 'FileConnectorBuilder'Set organization name
Arguments:
organization_name (str):
Returns:
DatasetsSearchBuilder- Returns itself to allow for method chaining.
Example:
builder.with_organization_name("organization_name")with_overwrite_files
def with_overwrite_files(overwrite_files: bool) -> 'FileConnectorBuilder'Set the overwrite file.
Arguments:
overwrite_files (bool):
Returns:
FileConnectorBuilder- Returns itself to allow for method chaining.
add_local_file
def add_local_file(local_file: str) -> 'FileConnectorBuilder'Add a single local file to be uploaded.
You can call this method multiple times or combine it with
add_local_multiple_files().
Arguments:
local_filestr - Local file path to be uploaded.
Returns:
FileConnectorBuilder- Returns itself to allow for method chaining.
Example:
builder.add_local_file("data/file1.csv")add_local_multiple_files
def add_local_multiple_files(local_files: list[str]) -> "FileConnectorBuilder"Add multiple local files to be uploaded.
The provided list can include one or more filesystem paths. They will be
appended to the same internal collection used by add_local_file, so you
can freely combine both methods:
builder.add_local_file(“foo.zip”).add_local_multiple_files([“bar.zip”, “baz.tar”])
Arguments:
local_fileslist[str] - List of file paths to upload.
Returns:
FileConnectorBuilder- Returns itself to allow for method chaining.
with_format
def with_format(format_data: str) -> 'FileConnectorBuilder'Formats the flat entities data based on the specified format (‘dict’, or ‘pandas’). By default, the data is returned as a dictionary.
Arguments:
format_datastr - The format to use for the data.
Example:
builder.with_format(‘dict’) builder.with_format(‘pandas’)
Returns:
SearchBuilderBase- Returns itself to allow for method chaining.
with_destiny_path
def with_destiny_path(path: str) -> 'FileConnectorBuilder'Set destiny path
Arguments:
path (str):
Returns:
FileConnectorBuilder- Returns itself to allow for method chaining.
Example:
builder.with_destiny_path("path")with_find_name
def with_find_name(find_file_name: str) -> 'FileConnectorBuilder'Set find by name
Arguments:
find_file_name (str):
Returns:
FileConnectorBuilder- Returns itself to allow for method chaining.
Example:
builder.with_find_file_name("find_file_name")
~~
<a id="opengate_data.file_connector.file_connector.FileConnectorBuilder.with_output_path"></a>
---
##### with\_output\_path
```python
def with_output_path(output_path: str) -> 'FileConnectorBuilder'
```
Set output path so that when downloading the file it is saved in that path
**Arguments**:
output_path (str):
**Returns**:
- `FileConnectorBuilder` - Returns itself to allow for method chaining.
**Example**:
~~~python
builder.with_output_path("output_path")add_remote_file
def add_remote_file(file: str) -> 'FileConnectorBuilder'Set remote filename
Arguments:
filename (str):
Returns:
FileConnectorBuilder- Returns itself to allow for method chaining.
Example:
builder.add_remote_file("filename")add_remote_multiple_files
def add_remote_multiple_files(files: list) -> 'FileConnectorBuilder'Set remote multiples filenames
Arguments:
filename (str):
Returns:
FileConnectorBuilder- Returns itself to allow for method chaining.
Example:
builder.add_remote_file("filename")from_dataframe
def from_dataframe(df: "pd.DataFrame",
*,
defaults: dict | None = None) -> 'FileConnectorBuilder'Assign a DataFrame that describes operations per row. Expected columns (depending on method):
- upload: local_file [req], destiny_path [opt], overwrite [opt] * If there is no destiny_path, use defaults[‘destiny_path’] or defaults[‘path’] or with_destiny_path(…) or “/” * default overwrite = False
- download: path [req], filename [req], output_path [opt] * path can come from column, defaults[‘path’], with_destiny_path(…)
- delete: path [req], filename [opt] (empty or absent -> delete the entire path)
Supported defaults: {“destiny_path”: str, “path”: str, “overwrite”: bool, “output_path”: str}
NOTE: if you mix from_dataframe with setters in download (path/filenames/output_path), then you must use all THREE setters; if not, use only from_dataframe.
upload
def upload() -> 'FileConnectorBuilder'Configures the builder to upload a file to the specified organization.
This method sets the internal state of the builder to prepare for a file upload operation. It does not execute the operation immediately but prepares the necessary configurations for when the execute method is called.
Returns:
FileConnectorBuilder- Returns itself to allow for method chaining.
Example:
builder.upload()list_all
def list_all() -> 'FileConnectorBuilder'Configures the builder to list files available in the specified organization.
This method sets the internal state of the builder to prepare for a file listing operation. It does not execute the operation immediately but prepares the necessary configurations for when the execute method is called.
Returns:
FileConnectorBuilder- Returns itself to allow for method chaining.
Example:
builder.list_all()list_one
def list_one() -> 'FileConnectorBuilder'Configures the builder to list a single file from the specified organization.
This method sets the internal state of the builder to prepare for a single file listing operation. It does not execute the operation immediately but prepares the necessary configurations for when the execute method is called.
Returns:
FileConnectorBuilder- Returns itself to allow for method chaining.
Example:
builder.list_one()download
def download() -> 'FileConnectorBuilder'Configures the builder to download a file from the specified organization.
This method sets the internal state of the builder to prepare for a file download operation. It does not execute the operation immediately but prepares the necessary configurations for when the execute method is called.
Returns:
FileConnectorBuilder- Returns itself to allow for method chaining.
Example:
builder.download()