Using CsvProcessor in Code - lgeorgieff/csv-processor GitHub Wiki
After you have defined the XML configuration you can start writing your code.
- Define all required generic operations
- Register all defined and required generic operations
- instantiate a CSV.Job.Job object with the path to your XML configuration file
- You can use the results by calling job.Results (Note: the CSV is only processed when you invoke the Results property)
let makeUpperCase(line: Line): option<Line> =
List.map(fun(cell: ICell) ->
{ Cell.Name = cell.Name; Cell.Value = cell.Value.ToUpper() } :> ICell) line
|> Some
let maskSpace(document: Lines): Lines =
List.map(fun(line: Line) ->
List.map(fun(cell: ICell) ->
{ Cell.Name = cell.Name; Cell.Value = cell.Value.Replace(' ', '_') } :> ICell) line) document
GenericTask.RegisterOperation("upper-case-transform", makeUpperCase)
GenericTask.RegisterOperation("space-transform", maskSpace)
let job = new CSV.JobJob("config.xml")
let results = job.Results