Summary
Allows the import of text representation of tabular data.
Properties
- types
-
Objectthat contains typeObjectsthat represent types available for the columns inTableImport.Type
Objectscontain two properties -lfor the level andsfor 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
Arrayis.Returns a type
Object. - convert ( text [, divider [, header [, types]]] )
-
Converts the passed text into an object with at most three properties:
- data contains the
ArrayofArrays(no header row) orObjects(with header row) containing the data of the table, - header contains the
Arrayof header cell titles (the headerArrayis not present when a header row does not exist), - types contains the
Arrayof typeObjectsof the corresponding columns.
Optional parameters set the divider
String(defaults to a tab character), the presence of a header row (Boolean) and sets theArrayof types of the columns in the table. The latter should be anArrayof 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
Objectand then calls thetoJSONStringon it.Returns a
String. - convert2Table ( text [, divider [, header [, types]]] )
-
Passes all the parameters to convert and then uses the returned
Objectto 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
Objectto 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
ArrayfromString(input type) to a specified type set in the typesArray.Returns
Array. - fillRow ( row, cols, header )
-
Fills the passed row
Arrayso that it contains the exact number of columns set by the colsInteger. If the headerBooleanis 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
Arrayis 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
Stringusing the dividerString.Returns
Array. - splitRows ( text )
-
Splits the text
Stringinto anArrayof lines.Returns
Array.