[Python] How split (chunk) a list of customers along month/year?

Discussão em 'Python' iniciado por Stack, Fevereiro 10, 2025.

  1. Stack

    Stack Membro Participativo

    I need to understand how I can generate a list for book list of customers for each month and year.

    In my file .txt I have list mail (like 5000) customers and need reserve booking for max 500 customers for each month.

    month= ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']

    year = ['2024', '2025', '2026', '2027', '2028', '2029', '2030', '2031', '2032']

    l_lines = ['a@a', 'b@b'.... ]

    def generate_list_email_month(l_lines):
    kk = [l_lines[i:i + 500] for i in range(0, len(l_lines), 500)]
    mail_k = []

    for i,x in enumerate(kk):
    list_mails = [y for y in x]
    mail_k.append(list_mails)

    return mail_k


    month_years = [f"{y}-{x}" for y in monthfor x in year]


    Now I need to generate list of 500 customers booked for month_years like:

    Jan-2024 = ['a@a', 'b@b'.... ]
    Feb-2024 = ['c@c', 'd@d'.... ]


    Any suggestions on how to do it?

    Thanks

    For now I get the same customers but for each Jan of Year like this:

    ['aa@aa|Jan-2024', 'aa@aa|Jan-2025', 'aa@aa|Jan-2026']

    Continue reading...

Compartilhe esta Página