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

Function export_to_csv

scrapegraphai/utils/data_export.py:28–44  ·  view source on GitHub ↗

Export data to a CSV file. :param data: List of dictionaries containing the data to export :param filename: Name of the file to save the CSV data

(data: List[Dict[str, Any]], filename: str)

Source from the content-addressed store, hash-verified

26
27
28def export_to_csv(data: List[Dict[str, Any]], filename: str) -> None:
29 """
30 Export data to a CSV file.
31
32 :param data: List of dictionaries containing the data to export
33 :param filename: Name of the file to save the CSV data
34 """
35 if not data:
36 logger.warning("No data to export")
37 return
38
39 keys = data[0].keys()
40 with open(filename, "w", newline="", encoding="utf-8") as f:
41 writer = csv.DictWriter(f, fieldnames=keys)
42 writer.writeheader()
43 writer.writerows(data)
44 logger.info("Data exported to %s", filename)
45
46
47def export_to_xml(

Callers 1

Calls 2

warningMethod · 0.80
infoMethod · 0.45

Tested by 1