import pandas as pd
import zipfile
import os

def list_and_zip_picture_hk(csv_file, zip_filename="images.zip"):
    # Load the CSV file
    df = pd.read_csv(csv_file)
    
    # Initialize a list to store file paths
    picture_files = []
    
    # Extract all values from the "picture_hk" column (excluding NaN values)
    for pictures in df["picture_hk"].dropna():
        picture_list = pictures.split(",")  # Split multiple files by comma
        picture_files.extend([pic.strip() for pic in picture_list])  # Append to list
    
    # Create a ZIP file and add listed files
    with zipfile.ZipFile(zip_filename, 'w') as zipf:
        for picture in picture_files:
            if os.path.exists("./" + picture):  # Check if file exists
                zipf.write(picture)
                print(f"Added: {picture}")
            else:
                print(f"File not found: {picture}")

# Example usage
if __name__ == "__main__":
    csv_file_path = "./jx_goods.csv"  # Replace with your actual file path
    list_and_zip_picture_hk(csv_file_path)
