A Telar case study. The distributor, the sales reps and the orders are fictional; the script is real and available.Español  ·  More case studies at telar.site

Four sales reps,one Excel file.

Every Monday someone at the warehouse copied the week's orders by hand from two Excel files, a CSV and a WhatsApp chat. This script does it in under a second and sets aside whatever a person should look at.

Built for Ferretería Hermanos Calderón, the same distributor as the month-end dashboard.

What comes in

This is what each sales rep sends. Same business, same products, four different ways of writing them down. The files are in Spanish, as the reps wrote them, and product and customer names stay in Spanish throughout because matching them is the job.

What it does

This is the actual log the script wrote while processing the files above. Replay it to see the order of the steps.

python consolidar_pedidos.py

    What comes out

    An Excel file with five sheets: the clean orders, what needs review, totals by customer, totals by product and the log. Here are the first rows.

    To review

    The script doesn't guess. When something doesn't add up, it sets the row aside with the reason and its exact position in the original file.

      How it's set up

      The sales reps don't have to change how they work. They keep sending their files as usual.

      1

      A shared folder

      Each rep drops their file in a Google Drive or OneDrive folder synced to the warehouse computer.

      2

      Runs on its own every night

      Windows Task Scheduler runs the script at 11 p.m. Nobody has to open anything.

      3

      The Excel file is waiting in the morning

      First thing, the consolidated file is in the reports folder, ready for invoicing or for feeding the sales dashboard.

      # Each rep names the same column differently. This dictionary maps them together.
      SINONIMOS = {
          'fecha':       ['fecha', 'fecha pedido', 'fec', 'dia'],
          'producto':    ['producto', 'referencia', 'descripcion', 'item'],
          'cantidad':    ['cant', 'cantidad', 'und', 'unidades'],
          'precio_unit': ['valor unit', 'precio', 'vr unit'],
          'total':       ['vr total', 'total', 'valor total'],
      }
      # A hand-typed product is accepted only if it is at least 80% similar to the catalog.
      UMBRAL_PRODUCTO = 80