# CSV import schema & Python script for on-call blocks – Guide

Canonical: https://x25pronto.ch/en/blog/vorlage-csv-importschema-und-python-skript-fur-abrufkontingente.html

VW Tiguan R · 320 PS 4MOTION · discreet · direct

EXPRESS COURIER · DIRECT · MON–SUN

Courier service Switzerland.
Express courier. Direct.
Also overnight.

x25pronto Switzerland takes goods direct to the destination. Small loads go by car. Larger loads go by van or Van XL. Direct, express and overnight trips run Monday to Sunday when a slot is free. Free times are shown in the booking calendar. This keeps the plan clear.

[Calculate price](https://x25pronto.ch/en/#quote)[How overnight works](https://x25pronto.ch/en/overnight.html)

Direct Mon–Sun Overnight Mon–Sun Car & van up to 1,000 kg

COURIER INSIGHTS

# Template: CSV import schema and Python script for on-call blocks

A clear CSV layout and a Python example that validates on-call blocks and uploads them via API. Built to integrate with Swiss ERPs and backends.

9 September 2026

## Quick answer

This post provides a straightforward CSV import schema and a practical Python script to validate on-call blocks locally and upload them to your ERP or internal backend via API. The example checks headers, types, business rules and only sends data when all rows pass validation. It fits Swiss procurement and logistics workflows and can be adapted to any ERP endpoint.

## What this covers

Companies often manage on-call blocks in spreadsheets. For automation you need a clean CSV format and reliable checks. This tutorial shows a simple schema, validation rules and a Python script for REST upload. The aim: fewer errors and faster imports into ERPs used in Zurich, Basel or Geneva.

## Recommended CSV import schema

Header (recommended order): - contract_id: string, required - sku: string, required - supplier_id: string, required - start_date: ISO-8601 (YYYY-MM-DD), required - end_date: ISO-8601 (YYYY-MM-DD), optional - quantity_total: integer ≥ 0, required - quantity_available: integer ≥ 0 ≤ quantity_total, required - location_code: string (optional, e.g. CH ZIP or site ID) - notes: optional Save as UTF-8 without BOM. Use dot for decimals and ISO dates for consistent parsing.

## Core validation rules

Check file basics: UTF-8, header present, no empty lines. Per row validate: - required fields present and non-empty - data types (integer, string, date) - numeric ranges: quantity_total ≥ 0, quantity_available between 0 and quantity_total - date logic: start_date ≤ end_date (if end_date set) - uniqueness: contract_id + sku should not repeat within a batch Report invalid rows; do not auto-overwrite existing data.

## Python example: flow and behavior

The script is split into three steps: 1) Read and parse with csv.DictReader 2) Validate with clear row-level messages 3) Build JSON payload and POST with requests It prints a validation summary and only posts when all rows are valid. You can add hooks to pre-check against your ERP API before upload.

## Security, error handling and idempotency

Use HTTPS and protect endpoints with API keys or OAuth. Implement idempotency keys (e.g. batch_id + timestamp) on POST so repeated calls do not create duplicate blocks. Log attempts and responses. On 4xx errors check payloads; on 5xx errors retry with exponential backoff.

## Adapting to your Swiss ERP

ERPs (e.g. Abacus, SAP Business One, Bexio or in-house systems) often require different field names or payload wrappers. Add a mapping layer: CSV field → internal field → API field. Test first in a staging environment or a vendor sandbox.

## Frequently asked questions

How do I test the script locally before production? Run it against a local mock API, for example a small Flask or FastAPI endpoint that validates the JSON. You can also use Postman or a vendor sandbox.

What if many rows miss required data? Export invalid rows to a separate CSV, fill missing values manually or with a helper script, then re-run validation. Automatic fill-in should only be used if rules are fully reliable.

How do I avoid duplicate uploads of the same file? Create a batch ID (for instance a hash of the file plus timestamp) and send it with the request. Your ERP can then detect repeated uploads. Server-side idempotency helps too.

Can I handle multiple locations in one file? Yes. Use location_code and document valid site IDs. Validate location_code against a reference table to avoid typos.

## Plan a courier trip in Switzerland

x25pronto Switzerland carries small and well packed shipments by car. Businesses can choose a direct courier trip or overnight service. Route, timing and shipment details can be entered online before booking. The guide price is then shown for the planned courier order.

[Direct courier →](https://x25pronto.ch/en/direct-courier.html)[Overnight →](https://x25pronto.ch/en/overnight.html)[Services →](https://x25pronto.ch/en/services.html)[Calculate guide price →](https://x25pronto.ch/en/#quote)

### At a glance: Template: CSV import schema and Python script for on-call blocks

Key points from this article. Follow the links to read each explanation.

What this covers Companies often manage on-call blocks in spreadsheets. [Read this section](https://x25pronto.ch/en/blog/vorlage-csv-importschema-und-python-skript-fur-abrufkontingente.html#courier-article-step-1)

Recommended CSV import schema Use dot for decimals and ISO dates for consistent parsing. [Read this section](https://x25pronto.ch/en/blog/vorlage-csv-importschema-und-python-skript-fur-abrufkontingente.html#courier-article-step-2)

Core validation rules Check file basics: UTF-8, header present, no empty lines. [Read this section](https://x25pronto.ch/en/blog/vorlage-csv-importschema-und-python-skript-fur-abrufkontingente.html#courier-article-step-3)

Python example: flow and behavior The script is split into three steps: [Read this section](https://x25pronto.ch/en/blog/vorlage-csv-importschema-und-python-skript-fur-abrufkontingente.html#courier-article-step-4)

Security, error handling and idempotency Use HTTPS and protect endpoints with API keys or OAuth. [Read this section](https://x25pronto.ch/en/blog/vorlage-csv-importschema-und-python-skript-fur-abrufkontingente.html#courier-article-step-5)

More on this topic These guides cover related questions: [Integrating on-call blocks into ERP and accounting](https://x25pronto.ch/en/blog/integration-von-abrufkontingenten-in-erp-und-buchhaltung.html) · [Cost-effective on-call blocks for SMEs](https://x25pronto.ch/en/blog/kostengunstige-abrufkontingente-fur-kmu.html)
