Skip to content

Latest commit

 

History

History
39 lines (32 loc) · 1.81 KB

TXTReader.new.md

File metadata and controls

39 lines (32 loc) · 1.81 KB

new TXTReader

The constructor function is established to create a TXTReader object.

Sample

//The content of the test.txt file is 
//"12345678901234567890
// 11111222223333344444
// 99999777777777722222"
var regFieldsDef="(.{5})(.{10})(.{5})";
var txtReader = new TXTReader("input/test.txt", regFieldsDef, "MS932"); 

//The content of the test.txt file is 
//"123456789012345678901111122222333334444499999777777777722222"
var txtReader = new TXTReader("input/test.txt", regFieldsDef, "MS932", 20); 

API

CallingReturning
new TXTReader (path, regFieldsDef)TXTReader
new TXTReader (path, regFieldsDef, encoding)TXTReader
new TXTReader (path, regFieldsDef, encoding, rowSize)TXTReader
new TXTReader (path, regFieldsDef, encoding, rowSize, skipRows)TXTReader
new TXTReader (path, regFieldsDef, encoding, rowSize, skipRows, rowsToRead)TXTReader
ParametersTypeDescription
pathStringThe relative file or folder path to the storage.
regFieldsDefStringA regular expression that defines the fields to be fetched.
encodingStringThe charset name of the text file. The default value is UTF-8.
rowSizeNumberThe binary size of a record. The default value is -1 means undefined.
skipRowsNumberThe count of rows to be skipped without reading. The default value is -1 means undefined.
rowsToReadNumberThe count of rows to be read. The default value is -1 means undefined.