Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions scrapegraphai/utils/convert_to_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,18 @@ def convert_to_csv(data: dict, filename: str, position: str = None):

Args:
data (dict): Data to be converted to CSV.
filename (str): Name of the CSV file (without the .csv extension).
position (str): Optional path where the file should be saved. If not provided,
the directory of the caller script will be used.

Raises:
ValueError: If the filename contains '.csv'.
FileNotFoundError: If the specified directory does not exist.
PermissionError: If the program lacks write permission for the directory.
TypeError: If the input data is not a dictionary.
Exception: For other potential errors during DataFrame creation or CSV saving.
"""

if ".csv" in filename:
raise ValueError("The filename should not contain '.csv'")
filename = filename.replace(".csv", "") # Remove .csv extension

# Get the directory of the caller script if position is not provided
if position is None:
Expand Down