Detailed Guide for Constructing a Correct CSV for PB Import Paragraphs

Last updated on
24 July 2024

The CSVProcessorPara class is responsible for processing CSV files to import paragraphs. Here are the key rules and validations applied during the CSV processing:

  1. Header Validation:
    • The CSV file must contain the following headers: csv_image_url, csv_image_alt, csv_image_title, csv_target_title, csv_target_tag, and csv_target_body.
    • Any missing or extra headers will result in an error, and the process will terminate.
  2. Row Length Check:
    • Each row in the CSV file must match the number of headers.
    • If the number of columns in a row does not match the number of headers, the row will be skipped, and a warning with the row number will be logged.
  3. Field Content Check:
    • At least one of the fields csv_image_url or csv_target_body must have content.
    • If both fields are empty, the row will be skipped, and a warning with the row number will be logged.
  4. Image URL Validation:
    • If csv_image_url is present, it must be a valid and readable URL.
    • If the URL is invalid and csv_target_body has content, the row will be skipped, and a warning with the row number will be logged indicating that the image URL is invalid, but body content is present.
    • If the URL is invalid and csv_target_body is empty, the row will be skipped, and an error with the row number will be logged.
  5. Paragraph Creation:
    • Child Paragraph: A child paragraph will be created using the provided data. If it fails, an error with the row number will be logged. If csv_target_body has content, it will be mentioned in the log.
    • Section Paragraph: A section paragraph will be created using the child paragraph data. If it fails, an error with the row number will be logged. If csv_target_body has content, it will be mentioned in the log.
  6. Parent Paragraph Creation:
    • If no section paragraphs are created, an error will be logged, and the process will terminate.
    • If successful, a parent paragraph will be created.
  7. Error Handling:
    • Any exceptions during the paragraph creation process will be caught, and an error with the row number will be logged.
    • If the CSV file cannot be opened, an error will be logged, and the process will terminate.
  8. Result Reporting:
    • The process returns a summary of the number of paragraphs processed and skipped, including the row numbers of skipped rows.

These rules ensure that the CSV data is processed correctly, and any issues are appropriately logged and communicated to the user for easy identification and correction.

Help improve this page

Page status: No known problems

You can: