پکیج مناسب برای ساخت فایل DBF برای ارسال دیسکت بیمه تامین اجتماعی
فایلی که با ماژول DBF پایتون ساخته میشود را قبول نمی کند
لطفا راهنمایی کنید
If you're generating a DBF file for submission to Iran's Social Security Organization (Tamin Ejtemaei), the problem is often not simply whether Python can create a DBF file. These systems are based on a fairly old DBF specification and can be very strict about the file structure, field definitions, encoding, and code page.
One important point from experience: don't assume UTF-8 is the correct encoding just because the data contains Persian. With older DBF-based systems, UTF-8 can actually break compatibility.
For Persian/Arabic data, you may need to use an Arabic-compatible code page such as Windows-1256, depending on what the receiving system expects.
For example:
from dbfread import DBF
table = DBF(
"insurance.dbf",
encoding="cp1256"
)
However, if you're creating the DBF rather than reading it, simply setting encoding="cp1256" may not be enough. You need to make sure the DBF writer creates the correct field types, field lengths, code-page information, and byte encoding expected by the Tamin Ejtemaei software.
Also, because these submission systems are quite old, UTF-8 can cause problems. In some cases, the practical solution is to use a custom encoding layer/code page that maps the required Persian and Arabic characters correctly before writing the DBF.
So I'd approach it this way:
The last step is especially useful with legacy systems: if you have one DBF file that Tamin Ejtemaei accepts, comparing its header, field descriptors, code-page information, and encoded Persian bytes against your generated file will usually reveal what's actually wrong.
Soroosh Morshedi
sorooshmorshedi.com
شاید پاسخ شما همینجا باشد