🪟 Windows TippsThe Gemini desktop app is now available for Windows(11.09.2026 um 17:06 Uhr)
🪟 Windows TippsWindows Authentication SMS not received or working(12.09.2026 um 11:54 Uhr)
⚠️ Malware / Trojaner / VirenWindows 11 just dropped the tool ransomware abused, Microsoft says don’t restore WMIC(10.09.2026 um 20:11 Uhr)
🕵️ SicherheitslückenDefender 0-Day ShieldBreak (CVE-2026-69414) nicht sauber gepatcht - BornCity(11.09.2026 um 12:52 Uhr)
🪟 Windows TippsServertimeout in Outlook über 10 Minuten verlängern(12.09.2026 um 15:10 Uhr)
🪟 Windows TippsThe Gemini desktop app is now available for Windows(11.09.2026 um 17:06 Uhr)
🪟 Windows TippsWindows Authentication SMS not received or working(12.09.2026 um 11:54 Uhr)
⚠️ Malware / Trojaner / VirenWindows 11 just dropped the tool ransomware abused, Microsoft says don’t restore WMIC(10.09.2026 um 20:11 Uhr)
🕵️ SicherheitslückenDefender 0-Day ShieldBreak (CVE-2026-69414) nicht sauber gepatcht - BornCity(11.09.2026 um 12:52 Uhr)
🪟 Windows TippsServertimeout in Outlook über 10 Minuten verlängern(12.09.2026 um 15:10 Uhr)

🔧 Programmierung 🕛 vor 3 Monaten 3 Min Lesezeit
0

Cleaning messy CSVs without pandas: 3 tiny no-install scripts

↗ Quelle (dev.to)
🗣️ Stimme:
📑 Inhaltsübersicht

Messy CSV exports are a tax on every data task: stray whitespace, duplicate rows, inconsistent headers, files too big to open. You don't always need pandas for this — Python's built-in csv module handles most of it with zero dependencies and code you can drop on any machine.



Here are three small patterns I reach for constantly.






1. Clean: dedupe, trim, fix headers






CODE
import csv

def clean(path, out):
seen = set()
with open(path, newline='', encoding='utf-8-sig') as f:
rows = list(csv.reader(f))
header = [h.strip().lower().replace(' ', '_') for h in rows[0]]
cleaned = []
for raw in rows[1:]:
cells = [c.strip() for c in raw]
if all(c == '' for c in cells):
continue # drop empty rows
key = tuple(cells)
if key in seen:
continue # drop duplicates
seen.add(key)
cleaned.append(cells)
with open(out, 'w', newline='', encoding='utf-8') as f:
w = csv.writer(f)
w.writerow(header)
w.writerows(cleaned)






Trims every cell, normalizes headers (First Name -> first_name), and removes empty/duplicate rows.






2. Split a huge CSV into chunks






CODE
import csv

def split(path, rows_per_file):
with open(path, newline='', encoding='utf-8-sig') as f:
reader = csv.reader(f)
header = next(reader)
chunk, part = [], 1
for row in reader:
chunk.append(row)
if len(chunk) >= rows_per_file:
_write(f'part{part}.csv', header, chunk); part += 1; chunk = []
if chunk:
_write(f'part{part}.csv', header, chunk)

def _write(name, header, rows):
with open(name, 'w', newline='', encoding='utf-8') as f:
w = csv.writer(f); w.writerow(header); w.writerows(rows)









3. Merge many CSVs into one






CODE
import csv, glob

def merge(pattern, out):
header = None
with open(out, 'w', newline='', encoding='utf-8') as o:
w = csv.writer(o)
for path in glob.glob(pattern):
with open(path, newline='', encoding='utf-8-sig') as f:
r = csv.reader(f)
h = next(r)
if header is None:
header = h; w.writerow(header)
w.writerows(r)









Why no pandas?



For one-off cleanups and small tools, the stdlib csv module is faster to ship: no install, runs anywhere Python 3.8+ runs, and the code stays readable enough to tweak for your own rules.






I cleaned these up into a tiny toolkit (proper CLI flags, edge cases, comments) so I stop rewriting them. If you'd rather grab them ready-made, it's $10 with full source: https://ko-fi.com/s/bfedf3fb78



What's your go-to for quick CSV wrangling?

Vollständiger Original-Bericht
Ausführliche Details, Code-Beispiele & Hersteller-Stellungnahme auf dev.to.
↗ Original-Artikel auf dev.to lesen
Wie bewertest du diesen Beitrag?
1 Klick Feedback
Teilen mit Netzwerk & Team:

Community-Analysen & Experten-Meinungen 0

Verfasse deine eigene Analyse, teile Workarounds oder diskutiere diesen Vorfall im Blog.
Noch keine Community-Analyse verfasst. Markiere einen Textabschnitt oder klicke oben auf Eigene Analyse verfassen“!
Community Pulse: Relevanz-Einschätzung
1 Klick Experten-Votum
🔴 Akute Relevanz 0%
🟡 In Evaluierung 0%
🟢 Keine Auswirkung 0%
Spannende Innovation 0%
Verwandte Story-Cluster & Quellen (Vektor-KI)
Port 8095 Engine
1 Quelle
Mastering Claude and ChatGPT: Developers Guide to Advanced Prompting
1 Quelle
Build vs Buy: When to Outsource Machine Learning Development
1 Quelle
SchemaCrawler LLM Context: Extract and Prune Relational DB Schemas
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Cleaning messy CSVs without pandas: 3 tiny no-install scripts

Thematisch verwandte Begriffe: Cleaning, messy, CSVs, without · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...