file_utils
_is_csv(data)
Check if data appears to be CSV-like.
Source code in griptape/utils/file_utils.py
_is_json(data)
_is_text(data)
Check if bytes are decodable as text.
Required since filetypes does not support this: https://github.com/h2non/filetype.py/issues/30
Source code in griptape/utils/file_utils.py
get_mime_type(file_path_or_bytes)
Attempt to determine the MIME type of a file or bytes.
If the input is a file path, we use the built-in mimetypes
package to guess the MIME type.
If the input is bytes, we use the filetype
library to determine the MIME type.
If the library cannot determine the MIME type (data missing magic bytes), we use a few heuristics to guess the type.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_path_or_bytes
|
str | bytes
|
The path to the file or the bytes to check. |
required |
Returns: The MIME type of the file or bytes.