MCPcopy Create free account
hub / github.com/Paper2Poster/Paper2Poster / parse_bytes

Method parse_bytes

camel/loaders/unstructured_io.py:158–188  ·  view source on GitHub ↗

r"""Parses a bytes stream and converts its contents into elements. Args: file (IO[bytes]): The file in bytes format to be parsed. **kwargs: Extra kwargs passed to the partition function. Returns: Union[List[Element], None]: List of elements after

(
        file: IO[bytes], **kwargs: Any
    )

Source from the content-addressed store, hash-verified

156
157 @staticmethod
158 def parse_bytes(
159 file: IO[bytes], **kwargs: Any
160 ) -> Union[List["Element"], None]:
161 r"""Parses a bytes stream and converts its contents into elements.
162
163 Args:
164 file (IO[bytes]): The file in bytes format to be parsed.
165 **kwargs: Extra kwargs passed to the partition function.
166
167 Returns:
168 Union[List[Element], None]: List of elements after parsing the file
169 if successful, otherwise `None`.
170
171 Notes:
172 Supported file types:
173 "csv", "doc", "docx", "epub", "image", "md", "msg", "odt",
174 "org", "pdf", "ppt", "pptx", "rtf", "rst", "tsv", "xlsx".
175
176 References:
177 https://docs.unstructured.io/open-source/core-functionality/partitioning
178 """
179
180 from unstructured.partition.auto import partition
181
182 try:
183 # Use partition to process the bytes stream
184 elements = partition(file=file, **kwargs)
185 return elements
186 except Exception as e:
187 warnings.warn(f"Failed to partition the file stream: {e}")
188 return None
189
190 @staticmethod
191 def clean_text_data(

Callers 1

processMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected