[Proposal] Custom CSV Dialect
See original GitHub issueUse-case
- Data is exported to be imported into another application.
- Some applications only support one specific CSV dialect. (For example, the German tax consultancy software DATEV)
- We need to give developers and administrators the choice to provide the dialect.
This will support the DRY principle, removing the need for case-specific implementations like this one: https://github.com/frappe/erpnext/blob/master/erpnext/regional/report/fichier_des_ecritures_comptables_[fec]/fichier_des_ecritures_comptables_[fec].js#L91-L97
Proposal
- Add Doctype “CSV Dialect” to frappe core.
- Extend UnicodeWriter to consider CSV Dialect
1. Add Doctype “CSV Dialect”
Proposed location: frappe.core.doctype.csv_dialect
Screenshots:
Fields:
Name | Type | Default |
---|---|---|
Quoting | Select | Minimal |
Quote Character | Data | " |
Delimiter | Data | , |
Doublequote | Checkbox | 1 |
Escape Character | Data | None |
Line Terminator | Data | \r\n |
Write Header | Checkbox | 1 |
Encoding | Data | utf-8 |
DocType:
https://github.com/alyf-de/frappe/blob/csv_dialect/frappe/core/doctype/csv_dialect/csv_dialect.json
2. Extend UnicodeWriter
Proposed: https://github.com/alyf-de/frappe/blob/csv_dialect/frappe/core/doctype/csv_dialect/csv_dialect.py
3. Give users the choice
In Report > Menu > Export > CSV
, provide a link field to choose the CSV Dialect. Provided CSV shall conform to the dialect.
Result
Before a call to to_csv
is made, we can ask the user to select a dialect which suits the target application. Required templates should come preinstalled and be set as default.
Thanks for reviewing. Maybe from @anandpdoshi who built the csv export?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:14
- Comments:5 (1 by maintainers)
Top GitHub Comments
I don’t think @anandpdoshi is still an (active) member here any longer. So we may need to find someone else to review this.
Looks good 👍 maybe we can encapsulate the behaviour inside the CSV Dialect DocType