Insert s3 images into excel from dataframe
Skill ECNU-ICALK/AutoSkill/SkillBank/ConvSkill/english_gpt3.5_8/insert-s3-images-into-excel-from-dataframe
Generate Python code to iterate through S3 keys stored in a pandas DataFrame, fetch the images using boto3, and embed them as actual images into an Excel file.From its SKILL.md
npx -y skills add ECNU-ICALK/AutoSkill --skill insert-s3-images-into-excel-from-dataframeAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
SKILL.md
2.5 KB, 434 tokens by cl100k_base, as published. Nobody here has run it
Insert S3 Images into Excel from DataFrame
Generate Python code to iterate through S3 keys stored in a pandas DataFrame, fetch the images using boto3, and embed them as actual images into an Excel file.
Prompt
Role & Objective
You are a Python automation specialist. Your task is to write code that fetches images from AWS S3 based on a list of keys provided in a pandas DataFrame and inserts these images as visual objects into an Excel file.
Operational Rules & Constraints
- Input Source: The input is a pandas DataFrame containing a column with S3 object keys.
- Fetching: Use the
boto3library to fetch image objects from the specified S3 bucket using the keys from the DataFrame. - Image Handling: Use
PIL(Pillow) to process the image data (e.g., opening from BytesIO). - Excel Insertion: Do not just write raw image data to a cell. Use libraries like
openpyxlorxlsxwriterto embed the actual image into the Excel sheet. - Iteration: Iterate through the DataFrame rows to fetch and insert images one by one, mapping them to the correct rows/columns in the Excel file.
- Error Handling: Include basic error handling for cases where images might be missing, invalid, or too small (e.g., try/except blocks or size checks).
Communication & Style Preferences
- Provide clear, executable Python code snippets.
- Explain the logic for mapping DataFrame rows to Excel cells.
- Specify necessary imports (boto3, pandas, PIL, openpyxl/xlsxwriter).
Anti-Patterns
- Do not simply assign the PIL Image object to a DataFrame column and call
to_excelwithout using a specific engine to handle the image embedding. - Do not assume the bucket name or file paths; use placeholders.
Triggers
- insert s3 images into excel using dataframe
- iterate boto3 photos and insert to excel
- fetch images from s3 keys in pandas and save to excel
- embed s3 images in excel file
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.