Added PandasExcelFileSheetName and PyListToString nodes as well fixing ShowText.js. Added dependency on lxml to address broken html node without lxml
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
from typing import Any, Dict, List
|
||||
|
||||
class PyListToString:
|
||||
"""
|
||||
Converts a Python list value to a Python string
|
||||
|
||||
category: Python wrapper
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the input types for the function.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary specifying required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"value": ("PYLIST", {})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("STRING",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
def f(self, value: List) -> tuple:
|
||||
"""
|
||||
Converts a Python list value to a Python string
|
||||
|
||||
Args:
|
||||
value (list): List value to convert.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing the converted value.
|
||||
"""
|
||||
return (str(value),)
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
from typing import Any, Dict
|
||||
import pandas as pd
|
||||
|
||||
|
||||
class PandasExcelFileSheetNames:
|
||||
"""
|
||||
Returns the string list of sheet names contained in the Excel file.
|
||||
|
||||
This node uses ExcelFile method using the openpyxl package.
|
||||
The openpyxl package is specified as a dependency in requirements.txt, so you should not need to manually install it.
|
||||
See [Pandas documentation](https://pandas.pydata.org/docs/reference/api/pandas.ExcelFile.html) for details.
|
||||
|
||||
To display the list, connect output to PyListToString node to convert the list to a string, then connect the output to Pandas Show Text node to display the string.
|
||||
|
||||
category: IO
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls) -> Dict[str, Any]:
|
||||
"""
|
||||
Defines the input types for the function.
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: A dictionary specifying required input types.
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"file_path": ("STRING", {"multiline": False}),
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES: tuple = ("PYLIST",)
|
||||
FUNCTION: str = "f"
|
||||
CATEGORY: str = "Data Analysis"
|
||||
|
||||
@classmethod
|
||||
def IS_CHANGED(cls, **kw):
|
||||
return float("NaN")
|
||||
|
||||
def f(self, file_path: str) -> tuple:
|
||||
"""
|
||||
Returns the string list of sheet names contained in the Excel file.
|
||||
|
||||
Args:
|
||||
file_path (str): The path to the Excel file.
|
||||
|
||||
Returns:
|
||||
tuple: A tuple containing a string list of sheet names.
|
||||
"""
|
||||
pylist = pd.ExcelFile(file_path, engine="openpyxl").sheet_names
|
||||
return (pylist,)
|
||||
Reference in New Issue
Block a user