MCPcopy Index your code
hub / github.com/ScrapeGraphAI/Scrapegraph-ai / handle_file

Method handle_file

scrapegraphai/nodes/fetch_node.py:145–169  ·  view source on GitHub ↗

Loads the content of a file based on its input type. Parameters: state (dict): The current state of the graph. input_type (str): The type of the input file (e.g., "pdf", "csv", "json", "xml", "md"). source (str): The path to the source file. Returns

(self, state, input_type, source)

Source from the content-addressed store, hash-verified

143 return state
144
145 def handle_file(self, state, input_type, source):
146 """
147 Loads the content of a file based on its input type.
148
149 Parameters:
150 state (dict): The current state of the graph.
151 input_type (str): The type of the input file (e.g., "pdf", "csv", "json", "xml", "md").
152 source (str): The path to the source file.
153
154 Returns:
155 dict: The updated state with the compressed document.
156
157 The function supports the following input types:
158 - "pdf": Uses PyPDFLoader to load the content of a PDF file.
159 - "csv": Reads the content of a CSV file using pandas and converts it to a string.
160 - "json": Loads the content of a JSON file.
161 - "xml": Reads the content of an XML file as a string.
162 - "md": Reads the content of a Markdown file as a string.
163 """
164
165 compressed_document = self.load_file_content(source, input_type)
166
167 # return self.update_state(state, compressed_document)
168 state.update({self.output[0]: compressed_document})
169 return state
170
171 def load_file_content(self, source, input_type):
172 """

Callers

nothing calls this directly

Calls 2

load_file_contentMethod · 0.95
updateMethod · 0.80

Tested by

no test coverage detected