Flat files (CSV, VDA, etc.) generation

Flat files (CSV, VDA) Generation with Flat Writer

FlatWriter provides a fast, non-cached, forward-only way to generate streams or files that contain flat file data. 

The writer accepts two parameters - 1. StreamWriter, to write the data to, 2. postfix (optional), to add to the end of each line (CRLF by default).

using (var stream = new MemoryStream())
	using (var writer = new StreamWriter(stream, Encoding.UTF8, 4096, true))
		using (var flatWriter = new FlatWriter(writer))

Check out the full example solutions here:







Auto padding

Lines beginning with tags must have the tag set as a data element. Positional lines can have each data element padded up to the Max length, by specifying the direction (pad left or pad right) and pad symbol (char), for example this data element:

[StringLength(10, 10, false, ' ')]
public string Country { get; set; }

 will be padded with empty space, up to 10 positions, to the left.

Was this article helpful?
2 out of 3 found this helpful