AGENT SKILL

read-csv-files

Use when you need to read and parse CSV files from the filesystem in Python. Handles encoding, missing values, and returns structured data.

License 许可
MIT
最近更新
2026-10-02
Stars
★ 93
Forks
8

01 前言 Front Matter

name
read-csv-files
description
Use when you need to read and parse CSV files from the filesystem in Python. Handles encoding, missing values, and returns structured data.

03 SKILL.md 正文

Reading CSV Files

Use pandas to read CSV files. Always handle potential encoding issues and inspect the data structure first.

import pandas as pd

# Basic read
df = pd.read_csv('/path/to/file.csv')

# With encoding fallback
try:
    df = pd.read_csv('/path/to/file.csv', encoding='utf-8')
except UnicodeDecodeError:
    df = pd.read_csv('/path/to/file.csv', encoding='latin-1')

# Inspect structure
print(df.columns.tolist())
print(df.head())
print(df.dtypes)
print(df.shape)

# Handle missing values
df = df.where(pd.notnull(df), None)

Always print column names and sample rows before processing to understand the schema.

04 同仓库更多 Skills