Python Lab

Data acquisition: how to collect good data from forms, files, APIs and the web

Where business data comes from, how to collect it reliably with simple tools and Python, and the consent and quality rules (including India's DPDP Rules) to follow.

Sury Kashyap·9 min read·Oct 11, 2026

Every analysis is only as good as the data that goes into it. Data acquisition is the first step: collecting the right data, in the right format, legally and reliably.

Four common sources

SourceExamplesTypical tool
Forms & surveysSign-ups, feedback, ordersOnline forms saving to a sheet or CSV
Files & exportsCSV/Excel exports from CRM, accounts, adsExcel, Python (pandas)
APIsPayments, e-commerce, weather, mapsPython requests
Web pagesPublic price lists, directoriesPython with care (see below)

Pulling data from an API with Python

import requests, pandas as pd

resp = requests.get("https://api.example.com/orders",
                    params={"from": "2026-10-01"},
                    headers={"Authorization": "Bearer YOUR_KEY"},
                    timeout=30)
resp.raise_for_status()
orders = pd.DataFrame(resp.json()["orders"])
orders.to_csv("data/orders_2026-10.csv", index=False)

Keep API keys out of your code (use environment variables) and never commit them to Git.

Build quality in at the start

  • Validate at entry: drop-downs, required fields and email checks stop bad data early.
  • Use consistent formats: dates as YYYY-MM-DD, one currency, one unit.
  • Record where data came from and when, so results can be traced and refreshed.

If you collect personal data in India, the Digital Personal Data Protection (DPDP) Rules, 2025, notified in November 2025 with a phased 18-month compliance period, require clear, standalone notices stating the specific purpose, valid consent, and prompt notification of affected people after a data breach. Collect only what you need. For web pages, respect each site's terms of use and robots.txt, and prefer an official API or data export when one exists.

Next: once data is collected, it needs cleaning and moving into one place. That is data engineering.

Further reading

33
LinkedIn X WhatsApp
2.4K16
SK

Sury Kashyap

Sury Kashyap is an independent consultant and certified corporate trainer with over 30 years in the Indian IT industry, focused on AI, communication, marketing and digital technologies with Python.

More about Sury →

Join the discussion

Have a question or a tip to add? Comments are reviewed before they're published.