# CSV to typed objects — prompt for Gemma

Prepare code to read a small CSV with explicit handling of empty values and row errors.

Canonical URL: https://boswidget.ru/en/csv-to-typed-objects-prompt-for-gemma/

Model: Gemma

Category: Code

Tags: CSV, parser, types

![CSV to typed objects](https://boswidget.ru/assets/images/text-preview-gm-tablica-csv-v-tipizirovannye-obekty-1200.663bb5cd4133.webp)

CSV to typed objects

## Prompt

Write a function in {language} to convert CSV into objects. Sample: {sample}. Format and types: {rules}. Use the language's standard CSV parser where available; do not use a simple split when quoted values are possible. Explicitly handle headers, empty values and type errors. Return errors with row numbers instead of silently skipping them. Do not install libraries or claim execution. Show the expected result for two sample rows.

## Template fields

- `{language}` — Language. Example input: Language, version and available standard library
- `{sample}` — CSV sample. Example input: A few anonymized rows with a header
- `{rules}` — Format. Example input: Delimiter, encoding, fields, types and missing-value rules

## Launch

[Open Gemma in YesAI](https://yesai.su/en/gemma)
