# CSV Locale Normalizer — Safe IDs, Decimals and Dates (`mick_mouse/my-actor-3`) Actor

Convert CSV to JSON with collision-safe headers, explicit decimal/date rules and a transformation audit. Preserve IDs and leading zeros by default. Supports supplied Unicode text or UTF-8/cp1252 bytes. No external URL fetching or inferred types.

- **URL**: https://apify.com/mick_mouse/my-actor-3.md
- **Developed by:** [Miguel Stuardo](https://apify.com/mick_mouse) (community)
- **Security:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $20.00 / 1,000 completed csv normalization reports

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## CSV Locale Normalizer — Exact Decimals & Header Audit

Convert CSV into JSON with explicit locale rules and an inspectable transformation audit. Designed for agent workflows and automation builders preparing exported records. Identifiers, leading zeros, whitespace and unselected cells remain strings by default. No type inference, AI model, network fetching, bank access or currency conversion.

### Example input

```json
{
  "csvText": "ID;Monto;Fecha;Nota\n0001;1.234,500;31/12/2024;sin cambios",
  "delimiter": ";",
  "encoding": "utf-8",
  "decimalColumns": {"monto": {"decimalSeparator": ",", "groupSeparator": "."}},
  "dateColumns": {"fecha": "%d/%m/%Y"}
}
```

The resulting record has `id: "0001"`, `monto: "1234.500"`, and `fecha: "2024-12-31"`. Exact decimal outputs are strings to avoid JSON floating-point loss. One dataset item contains all records and the audit.

### Input rules

Supply exactly one of `csvText` (already decoded Unicode) or `csvBase64` (encoded file bytes); remove the example csvText field when using base64. Required delimiter: comma, semicolon, tab, or pipe. Encoding is utf-8 (default), utf-8-sig, or cp1252; cp1252 requires base64 bytes. Decoding is strict.

`trimValues` and `emptyToNull` default to false. Enable only when intended. `decimalColumns` maps normalized column names to decimalSeparator (dot/comma) and optional groupSeparator (empty/dot/comma/space, different from decimal). Grouping is strictly checked; exponent syntax and nonfinite values are rejected. `dateColumns` maps normalized names to `%Y-%m-%d`, `%d/%m/%Y`, `%m/%d/%Y`, or `%Y%m%d`; input must exactly match format and a valid calendar date. Output is ISO date. Conversion applies to each non-null cell in the selected column. Unknown columns, conflicting conversions or invalid values reject the entire report.

Headers are stripped and lowercased; non-word runs become underscores. Empty headers receive positional names. Collisions get unique suffixes. Audit maps every original header position to its normalized name. For complex headers, first run with empty conversion objects, inspect the mapping, then select rules. The audit includes row count, skipped blank rows, trimmed/null cell counts and per-column conversion counts. Duplicate records are retained. Formula-looking strings remain inert JSON text; exercise care if later exporting to spreadsheets.

### Limits

Source <=1,000,000 bytes; serialized JSON request <=2,100,000 UTF-8 bytes; <=10,000 records, <=200 columns; output <=8,000,000 bytes. Python CSV field-length restrictions can reject very large individual cells. Blank physical rows are skipped and counted. Row-width mismatches and malformed quoted CSV are rejected. No XLSX, PDF, file URL intake, timestamps, timezone handling, deduplication, fuzzy matching, currency verification, or ERP writes. A successful conversion does not certify accounting correctness.

### Pricing and delivery

One completed report is one `normalization-report` event, independent of row count. Check the Pricing tab for the configured price and any automatic Actor start event. Invalid input is validated before requesting our custom report event; platform start/usage charges may still apply. No separate custom per-row charge is requested.

Output persistence and charging are not atomic. On restart, an existing report is retained without requesting an additional custom event. A crash between storage and charging can leave an unbilled report; inspect billing before retrying a failed delivery.

### Privacy

This hosted version receives input via Apify and stores a report in the run dataset. Apify also stores run inputs and platform metadata according to its settings and policies. Do not assume zero retention. Send only data you are authorized to process and manage access/retention through platform settings. Application code does not fetch external URLs, execute CSV formulas, call a language model, or log CSV contents.

### Automation

Invoke via the Apify API or compatible Apify MCP client with the input above. Availability, pricing and access are controlled through the published Actor. This tool is useful for explicit locale transformation and audit; generic CSV converters are also available and no uniqueness claim is made.

# Actor input Schema

## `csvText` (type: `string`):

Decoded Unicode CSV text; omit when using csvBase64. Never a URL.

## `csvBase64` (type: `string`):

For encoded file bytes. Supply exactly one of csvText or csvBase64; remove csvText if using this.

## `delimiter` (type: `string`):

Explicit separator; never inferred.

## `encoding` (type: `string`):

cp1252 is available only with base64 bytes.

## `trimValues` (type: `boolean`):

Opt-in transformation; disabled by default.

## `emptyToNull` (type: `boolean`):

Opt-in transformation; disabled by default.

## `decimalColumns` (type: `object`):

Rules keyed by normalized column names. See README for accepted formats.

## `dateColumns` (type: `object`):

Rules keyed by normalized column names. See README for accepted formats.

## Actor input object example

```json
{
  "csvText": "ID;Monto;Fecha;Nota\n0001;1.234,500;31/12/2024;sin cambios",
  "delimiter": ";",
  "encoding": "utf-8",
  "trimValues": false,
  "emptyToNull": false,
  "decimalColumns": {
    "monto": {
      "decimalSeparator": ",",
      "groupSeparator": "."
    }
  },
  "dateColumns": {
    "fecha": "%d/%m/%Y"
  }
}
```

# Actor output Schema

## `report` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "csvText": `ID;Monto;Fecha;Nota
0001;1.234,500;31/12/2024;sin cambios`,
    "decimalColumns": {
        "monto": {
            "decimalSeparator": ",",
            "groupSeparator": "."
        }
    },
    "dateColumns": {
        "fecha": "%d/%m/%Y"
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("mick_mouse/my-actor-3").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "csvText": """ID;Monto;Fecha;Nota
0001;1.234,500;31/12/2024;sin cambios""",
    "decimalColumns": { "monto": {
            "decimalSeparator": ",",
            "groupSeparator": ".",
        } },
    "dateColumns": { "fecha": "%d/%m/%Y" },
}

# Run the Actor and wait for it to finish
run = client.actor("mick_mouse/my-actor-3").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "csvText": "ID;Monto;Fecha;Nota\\n0001;1.234,500;31/12/2024;sin cambios",
  "decimalColumns": {
    "monto": {
      "decimalSeparator": ",",
      "groupSeparator": "."
    }
  },
  "dateColumns": {
    "fecha": "%d/%m/%Y"
  }
}' |
apify call mick_mouse/my-actor-3 --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,mick_mouse/my-actor-3"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/Ni6CwkA9byFCVVfPi/builds/xY8hukSk0flawhWz6/openapi.json
