CsvEditSharp is a CSV editor that describes read / write settings with C # script.
In the script, write read / write settings using API of "CsvHelper" which is a open source .Net class library.
[Script example]
-------------------
/* Get the API object that can be used in this script */
ICsvEditSharpApi api = GetCsvEditSharpApi();
/* Encoding of CSV file */
api.Encoding = Encoding.GetEncoding("utf-8");
/* Configuration settings for CSV Helper */
api.CsvConfiguration = new CsvConfiguration( CultureInfo.GetCultureInfo("en-US"))
{
HasHeaderRecord = true
};
/*****************************
Definition of record class
*****************************/
class FieldData
{
public string Name { get; set; }
[Format("d")]
public DateTime Birthday { get; set; }
public Gender Gender { get; set; }
public bool Married { get; set; }
[NumberStyles(NumberStyles.Currency)]
[Format("C")]
public decimal PocketMoney { get; set; }
}
/****************************************
Define the enum type of selection item
****************************************/
enum Gender
{
Male,
Female,
Other
}
/**********************************************
Register auto class maps in CSV reader/writer
**********************************************/
api.RegisterClassMap();
/************************
Add custom validations
************************/
api.AddValidation(
m => m.Birthday,
dt => dt.Date (
m => m.PocketMoney,
n => n > 0 && n < 10000,
"PocketMoney must be in the range $0 to $10000.");
-------------------
For details of APIs that can be used in scripts, see below.
[GitHub]
https://github.com/pierre3/CsvEditSharp
[CsvHelper]
https://joshclose.github.io/CsvHelper/