Summary
Allows the import of text representation of tabular data.
Properties
- types
-
Object
that contains typeObjects
that represent types available for the columns inTableImport
.Type
Objects
contain two properties -l
for the level ands
for the string representation of the type.
Methods
- cellType ( value )
-
Determines what type the passed value is.
Returns a type
Object
. - colType ( column )
-
Determines what type the data in the passed column
Array
is.Returns a type
Object
. - convert ( text [, divider [, header [, types]]] )
-
Converts the passed text into an object with at most three properties:
- data contains the
Array
ofArrays
(no header row) orObjects
(with header row) containing the data of the table, - header contains the
Array
of header cell titles (the headerArray
is not present when a header row does not exist), - types contains the
Array
of typeObjects
of the corresponding columns.
Optional parameters set the divider
String
(defaults to a tab character), the presence of a header row (Boolean
) and sets theArray
of types of the columns in the table. The latter should be anArray
of type keywords. For supported types check the types property.Returns an
Object
. - data contains the
- convert2JSON ( text [, divider [, header [, types]]] )
-
Passes all the parameters to convert to get the
Object
and then calls thetoJSONString
on it.Returns a
String
. - convert2Table ( text [, divider [, header [, types]]] )
-
Passes all the parameters to convert and then uses the returned
Object
to create an html table.The table is returned with thead if header row exists and tbody that contains the data.
Returns
HTMLTableElement
. - convert2Input ( text [, divider [, header [, types]]] )
-
Passes all the parameters to convert and then uses the returned
Object
to create a fieldset with input elements that contain the data.The input elements are named 'header_'+i for headers and 'cell_'+r+'_'+i for data. Types are also returned as 'type_'+i.
Returns
HTMLFieldsetElement
. - convertRow ( row, types )
-
Converts the row
Array
fromString
(input type) to a specified type set in the typesArray
.Returns
Array
. - fillRow ( row, cols, header )
-
Fills the passed row
Array
so that it contains the exact number of columns set by the colsInteger
. If the headerBoolean
is set to true the values for the header row are used as fill-ins.Returns
Array
. - findNewline ( text )
-
Finds the characters that split rows in text
String
- can be any combination of CR and LF.Returns
String
. - hasHeader ( firstrow, types )
-
Determines if the first row passed in as the firstrow
Array
is a header row by comparing the cell types and the corresponding column types passed in through the typesArray
.Returns
Boolean
. - splitCells ( text, divider )
-
Splits the text
String
using the dividerString
.Returns
Array
. - splitRows ( text )
-
Splits the text
String
into anArray
of lines.Returns
Array
.