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:
- 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, andcsv_target_body. - Any missing or extra headers will result in an error, and the process will terminate.
- The CSV file must contain the following headers:
- 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.
- Field Content Check:
- At least one of the fields
csv_image_urlorcsv_target_bodymust have content. - If both fields are empty, the row will be skipped, and a warning with the row number will be logged.
- At least one of the fields
- Image URL Validation:
- If
csv_image_urlis present, it must be a valid and readable URL. - If the URL is invalid and
csv_target_bodyhas 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_bodyis empty, the row will be skipped, and an error with the row number will be logged.
- If
- 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_bodyhas 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_bodyhas content, it will be mentioned in the log.
- 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
- 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.
- 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.
- 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:
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion