Kiểm tra file CSV online
Kiểm tra CSV theo Frictionless Table Schema hoặc quy tắc cột: kiểu, bắt buộc, không trùng, khoảng giá trị, regex, danh sách, SĐT / CCCD / MST Việt Nam.
Kết quả
Bấm “Chạy” để xem kết quả.
Gửi CSV (csv dạng văn bản, body thô hoặc file; tự nhận dấu phân cách và mã tiếng Việt cũ) cùng rules — {"email": "required|email", "luong": "integer|min:0", "sdt": "vn_phone", "phong": "enum:KT,HR"} — hoặc schema theo Frictionless (fields có type, format, constraints required / unique / minimum / maximum / minLength / maxLength / pattern / enum, cùng primaryKey, uniqueKeys và missingValues).
Kiểu: string, integer, number (nhận cả dạng 1.234.567,5), boolean, date (format như %d/%m/%Y, hoặc any), datetime, time, year, yearmonth, duration, geopoint, object, array; định dạng chuỗi email, uri, uuid và kiểm tra riêng cho Việt Nam: vn_phone (di động / cố định, dạng +84), vn_cccd (CCCD 12 số, mã tỉnh và năm sinh), vn_tax_code (MST 10 hoặc 13 số, kiểm tra số kiểm), vn_bank_account, vn_plate.
Báo cáo gồm valid, số lỗi theo mã, tóm tắt từng cột (số lỗi, ô trống, min / max) và tối đa max_errors (1.000) lỗi kèm số dòng (như bảng tính, dòng tiêu đề là dòng 1), cột, trường, giá trị và thông báo. Lỗi cấu trúc — thiếu hoặc thừa cột, tiêu đề trùng, dòng thiếu / thừa ô, dòng trống — luôn được kiểm tra. Tối đa 500.000 dòng; không lưu dữ liệu.
Dùng trong code của bạn
curl -X POST "https://apibox.io.vn/v1/csv-validate" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"csv":"ma_nv,ho_ten,sdt,mst,luong\nNV001,Nguyễn Văn An,0912345678,0100109106,15000000\nNV002,,0123456,0100109107,-5\n","rules":{"ma_nv":"required|unique","ho_ten":"required","sdt":"vn_phone","mst":"vn_tax_code","luong":"integer|min:0"}}'const res = await fetch('https://apibox.io.vn/v1/csv-validate', {
method: 'POST',
headers: {
Authorization: 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
"csv": "ma_nv,ho_ten,sdt,mst,luong\nNV001,Nguyễn Văn An,0912345678,0100109106,15000000\nNV002,,0123456,0100109107,-5\n",
"rules": {
"ma_nv": "required|unique",
"ho_ten": "required",
"sdt": "vn_phone",
"mst": "vn_tax_code",
"luong": "integer|min:0"
}
}),
});
const data = await res.json();
console.log(data);import requests
res = requests.post(
"https://apibox.io.vn/v1/csv-validate",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={"csv": "ma_nv,ho_ten,sdt,mst,luong\nNV001,Nguyễn Văn An,0912345678,0100109106,15000000\nNV002,,0123456,0100109107,-5\n", "rules": {"ma_nv": "required|unique", "ho_ten": "required", "sdt": "vn_phone", "mst": "vn_tax_code", "luong": "integer|min:0"}},
timeout=30,
)
print(res.json())<?php
$ch = curl_init('https://apibox.io.vn/v1/csv-validate');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => ['Authorization: Bearer YOUR_API_KEY', 'Content-Type: application/json'],
CURLOPT_POSTFIELDS => '{"csv":"ma_nv,ho_ten,sdt,mst,luong\\nNV001,Nguyễn Văn An,0912345678,0100109106,15000000\\nNV002,,0123456,0100109107,-5\\n","rules":{"ma_nv":"required|unique","ho_ten":"required","sdt":"vn_phone","mst":"vn_tax_code","luong":"integer|min:0"}}',
]);
$response = curl_exec($ch);
print_r(json_decode($response, true));Tài liệu API → Nhận API key miễn phí
Hỏi đáp
Nên dùng rules hay schema?
rules là cú pháp gọn để kiểm tra nhanh; schema theo chuẩn Frictionless Table Schema, có thêm khoá chính / khoá duy nhất, giá trị trống và tuỳ chọn số (decimalChar, groupChar).
Số dòng báo lỗi tính thế nào?
Như bảng tính: dòng tiêu đề là dòng 1, dòng dữ liệu đầu tiên là dòng 2.
Có kiểm tra file Excel được không?
Hãy xuất sheet ra CSV trước, hoặc chuyển bằng /v1/xlsx-convert?format=csv.