# Read File > Lee cualquier archivo de datos (CSV, JSON, Parquet, Avro, Excel, spatial, SQLite) o URL remota (S3, HTTPS) usando DuckDB. No sirve para código fuente. Fuente: https://skillsagentes.com/skills/duckdb/duckdb-skills/read-file Markdown: https://skillsagentes.com/skills/duckdb/duckdb-skills/read-file.md Repositorio: https://github.com/duckdb/duckdb-skills Autor: duckdb Licencia: MIT Actualizado: hace 5 meses Coste de contexto: 56 tok instalada, 919 tok al activarse, 919 tok con todos los archivos del bundle Bundle: 1 archivo, 4 KB Permisos que pide: bash ## Instalación Un skill son archivos markdown: los mismos archivos valen para cualquier agente y lo único que cambia es el directorio de destino, es decir la bandera `--agent`. Añade `-g` para instalarlo en todos los proyectos de la máquina. ```bash # Claude Code npx -y skills add duckdb/duckdb-skills --skill read-file --agent claude-code # Cursor npx -y skills add duckdb/duckdb-skills --skill read-file --agent cursor # Codex npx -y skills add duckdb/duckdb-skills --skill read-file --agent codex # Gemini CLI npx -y skills add duckdb/duckdb-skills --skill read-file --agent gemini # Windsurf npx -y skills add duckdb/duckdb-skills --skill read-file --agent windsurf # Cline npx -y skills add duckdb/duckdb-skills --skill read-file --agent cline ``` ## Qué hace - Ejecuta un único comando DuckDB con una macro inline read_any que detecta el formato del archivo por extensión y lo lee - Resuelve rutas de archivo con find si se da solo el nombre, sin ruta completa - Antepone LOAD/CREATE SECRET necesarios para leer URLs remotas en S3, HTTPS, GCS o Azure - Muestra DESCRIBE, row count y las primeras 20 filas del archivo, y responde una pregunta sobre los datos ## Cuándo usarla - El usuario menciona un archivo de datos (CSV, JSON, Parquet, Avro, Excel, spatial, SQLite) o una URL remota - El usuario pregunta 'qué hay en este archivo' - El usuario quiere previsualizar o perfilar un dataset ## Cuándo no - El archivo es código fuente, no un archivo de datos ## Qué la activa - "¿Qué hay en este archivo data.csv?" - "Léeme el archivo s3://mi-bucket/datos.parquet y descríbelo" - "Previsualiza este archivo Excel y dime cuántas filas tiene" ## Antes de instalar - Requiere el binario duckdb instalado (si falta, se sugiere usar la skill install-duckdb) y, según el formato, extensiones como spatial, sqlite_scanner o httpfs/azure. - runs shell commands ## Archivos - SKILL.md — 4 KB ## SKILL.md Reproducido tal cual desde duckdb/duckdb-skills bajo MIT. Esta sección es el documento original y está en inglés. You are helping the user read and analyze a data file using DuckDB. Filename given: `$0` Question: `${1:-describe the data}` ## Step 1 — Read it `RESOLVED_PATH` is `$0`. If the user gave a bare filename (no `/`), resolve it to a full path with `find` first. Run a single DuckDB command that defines the `read_any` macro inline and reads the file. For **remote files**, prepend the necessary LOAD/SECRET before the macro: | Protocol | Prepend | |---|---| | `https://` / `http://` | `LOAD httpfs;` | | `s3://` | `LOAD httpfs; CREATE SECRET (TYPE S3, PROVIDER credential_chain);` | | `gs://` / `gcs://` | `LOAD httpfs; CREATE SECRET (TYPE GCS, PROVIDER credential_chain);` | | `az://` / `azure://` / `abfss://` | `LOAD httpfs; LOAD azure; CREATE SECRET (TYPE AZURE, PROVIDER credential_chain);` | For **local files**, no prefix needed. ```bash duckdb -csv -c " CREATE OR REPLACE MACRO read_any(file_name) AS TABLE WITH json_case AS (FROM read_json_auto(file_name)) , csv_case AS (FROM read_csv(file_name)) , parquet_case AS (FROM read_parquet(file_name)) , avro_case AS (FROM read_avro(file_name)) , blob_case AS (FROM read_blob(file_name)) , spatial_case AS (FROM st_read(file_name)) , excel_case AS (FROM read_xlsx(file_name)) , sqlite_case AS (FROM sqlite_scan(file_name, (SELECT name FROM sqlite_master(file_name) LIMIT 1))) , ipynb_case AS ( WITH nb AS (FROM read_json_auto(file_name)) SELECT cell_idx, cell.cell_type, array_to_string(cell.source, '') AS source, cell.execution_count FROM nb, UNNEST(cells) WITH ORDINALITY AS t(cell, cell_idx) ORDER BY cell_idx ) FROM query_table( CASE WHEN file_name ILIKE '%.json' OR file_name ILIKE '%.jsonl' OR file_name ILIKE '%.ndjson' OR file_name ILIKE '%.geojson' OR file_name ILIKE '%.geojsonl' OR file_name ILIKE '%.har' THEN 'json_case' WHEN file_name ILIKE '%.csv' OR file_name ILIKE '%.tsv' OR file_name ILIKE '%.tab' OR file_name ILIKE '%.txt' THEN 'csv_case' WHEN file_name ILIKE '%.parquet' OR file_name ILIKE '%.pq' THEN 'parquet_case' WHEN file_name ILIKE '%.avro' THEN 'avro_case' WHEN file_name ILIKE '%.xlsx' OR file_name ILIKE '%.xls' THEN 'excel_case' WHEN file_name ILIKE '%.shp' OR file_name ILIKE '%.gpkg' OR file_name ILIKE '%.fgb' OR file_name ILIKE '%.kml' THEN 'spatial_case' WHEN file_name ILIKE '%.ipynb' THEN 'ipynb_case' WHEN file_name ILIKE '%.db' OR file_name ILIKE '%.sqlite' OR file_name ILIKE '%.sqlite3' THEN 'sqlite_case' ELSE 'blob_case' END ); DESCRIBE FROM read_any('RESOLVED_PATH'); SELECT count(*) AS row_count FROM read_any('RESOLVED_PATH'); FROM read_any('RESOLVED_PATH') LIMIT 20; " ``` **If this fails:** - **`duckdb: command not found`** → invoke `/duckdb-skills:install-duckdb` and retry. - **Missing extension** (e.g. spatial files, xlsx, sqlite) → retry with `INSTALL spatial; LOAD spatial;` or `INSTALL sqlite_scanner; LOAD sqlite_scanner;` prepended before the macro. - **Wrong reader / parse error** → use the correct `read_*` function directly instead of `read_any`. ## Step 2 — Answer Using the schema, row count, and sample rows, answer: `${1:-describe the data: summarize column types, row count, and any notable patterns.}` ## Dónde encaja - Categoría: [Datos y analítica](https://skillsagentes.com/categorias/datos-analitica.md) — Consulta, limpia y visualiza datos sin salir del agente. - Creador: [duckdb](https://skillsagentes.com/creators/duckdb.md) — 0 skills en el directorio - [Todas las skills](https://skillsagentes.com/skills.md) - [Ranking de instalaciones](https://skillsagentes.com/ranking.md) ## Otras skills del mismo repositorio - [S3 Explore](https://skillsagentes.com/skills/duckdb/duckdb-skills/s3-explore.md): Explora y consulta datos en S3, Cloudflare R2, GCS, MinIO o cualquier almacenamiento compatible con S3, sin necesidad de descargarlos. - [Spatial](https://skillsagentes.com/skills/duckdb/duckdb-skills/spatial.md): Responde preguntas sobre datos espaciales con DuckDB: ubicaciones, coordenadas, distancias, mapas, direcciones, formatos como GeoJSON, Shapefile, GeoPackage, GPX o GeoParquet, usando también Overture Maps. - [Convert File](https://skillsagentes.com/skills/duckdb/duckdb-skills/convert-file.md): Convierte cualquier archivo de datos a otro formato: CSV, Parquet, JSON, Excel, GeoJSON y más, usando DuckDB. - [Duckdb Docs](https://skillsagentes.com/skills/duckdb/duckdb-skills/duckdb-docs.md): Busca en la documentación de DuckDB y DuckLake y en posts del blog, devolviendo fragmentos relevantes mediante búsqueda de texto completo contra un índice local cacheado. - [Read Memories](https://skillsagentes.com/skills/duckdb/duckdb-skills/read-memories.md): Busca en los logs de sesiones pasadas de Claude Code para recordar decisiones, patrones o trabajo pendiente. Úsalo cuando el usuario mencione conversaciones anteriores o necesites contexto previo. --- Skills Agentes · [Índice de páginas en markdown](https://skillsagentes.com/sitemap.md) · [Inicio](https://skillsagentes.com/index.md)