csv-reader-poc / load_poc.py
AeonAIRisk's picture
Upload load_poc.py with huggingface_hub
749be66 verified
Raw
History Blame Contribute Delete
807 Bytes
"""Load PoC for csv_reader. Usage: python load_poc.py [csv_reader.pkl]"""
import pickle, sys, pathlib
p = pathlib.Path(sys.argv[1]) if len(sys.argv) > 1 else pathlib.Path(__file__).with_name("csv_reader.pkl")
obj = pickle.loads(p.read_bytes())
print("type:", type(obj))
# best-effort content dump
if hasattr(obj, "as_string"):
print(obj.as_string()[:500])
elif isinstance(obj, (str, bytes, dict, list, tuple)):
print(repr(obj)[:500])
else:
try:
print(repr(list(obj))[:500])
except Exception:
try:
from lxml import etree
if hasattr(obj, "getroot"):
print(etree.tostring(obj, encoding=str)[:500])
else:
print(repr(obj)[:500])
except Exception:
print(repr(obj)[:500])