Class GoogleSheetReader
java.lang.Object
com.northconcepts.datapipeline.core.DataObject
com.northconcepts.datapipeline.core.Endpoint
com.northconcepts.datapipeline.core.DataEndpoint
com.northconcepts.datapipeline.core.DataReader
com.northconcepts.datapipeline.core.AbstractReader
com.northconcepts.datapipeline.google.sheets.GoogleSheetReader
Reads records from one sheet, or one range, of a Google Sheets spreadsheet opened as a
GoogleSheetDocument; the
sheet is the one the range names, else the named sheet, else the sheet at the index. Rows are loaded when the reader opens.-
Nested Class Summary
Nested classes/interfaces inherited from class com.northconcepts.datapipeline.core.DataEndpoint
DataEndpoint.State -
Field Summary
Fields inherited from class com.northconcepts.datapipeline.core.AbstractReader
currentRecord, fieldNames, lastRow, startingRowFields inherited from class com.northconcepts.datapipeline.core.DataReader
fieldLineage, recordLineageFields inherited from class com.northconcepts.datapipeline.core.DataEndpoint
lastRecord, PRODUCT, PRODUCT_VERSION, VENDOR, XML_INPUT_FACTORY_KEYFields inherited from class com.northconcepts.datapipeline.core.Endpoint
BUFFER_SIZE, captureElapsedTime, DEFAULT_READ_BUFFER_SIZEFields inherited from class com.northconcepts.datapipeline.core.DataObject
id, log, name, TIMESTAMP_FORMAT -
Constructor Summary
ConstructorsConstructorDescriptionGoogleSheetReader(GoogleSheetDocument document) Creates a reader for the given document, which must be opened by the caller and is not closed by this reader unlesssetAutoCloseDocument(boolean)is enabled. -
Method Summary
Modifier and TypeMethodDescriptionaddExceptionProperties(DataException exception) Adds this endpoint's current state to aDataException.voidclose()Indicates that this endpoint has finished reading or writing.protected booleanfillRecord(Record record) Populates the given record with the next row's values; returns false at the end of the input.longReturns the 0-based index of the next row to read within the loaded sheet or range.getRange()intintbooleanIndicates if the GoogleSheetDocument should be closed when this endpoint is closed.voidopen()Makes this endpoint ready for reading or writing.setAutoCloseDocument(boolean autoCloseDocument) Indicates if the GoogleSheetDocument should be closed when this endpoint is closed.setDescription(String description) Sets the optional text shown for this endpoint inEndpoint.toString()and exception properties.setFieldNames(String... fieldNames) Sets the names given to each record's fields, taking precedence over names in the first row; must be called beforeAbstractReader.open().setFieldNames(Collection<String> fieldNames) Sets the names given to each record's fields, taking precedence over names in the first row; must be called beforeAbstractReader.open().setFieldNamesInFirstRow(boolean fieldNamesInFirstRow) Indicates if the first row holds the field names instead of data (default is false); must be called beforeAbstractReader.open().setLastRow(int lastRow) Sets the 0-based index of the last row to read or -1 to read to the end (default is -1).Sets the A1-notation range to read, such asA1:B3orSheet1!A1:B3; a range without a sheet prefix is read from the sheet named or indexed on this reader (default is null for the whole sheet).setSheetIndex(int sheetIndex) Sets the 0-based index of the sheet to read when no sheet name or range names one (defaults to 0).setSheetName(String sheetName) Sets the name of the sheet to read; when set, it is used instead of the sheet index (default is null).setSkipEmptyRows(boolean skipEmptyRows) Indicates that rows with only null values should not be returned by the reader (default is false).setStartingColumn(int startingColumn) Sets the 0-based index of the first column read; earlier columns are skipped (defaults to 0).setStartingRow(int startingRow) Sets the 0-based index of the first row to read; earlier rows are skipped when the reader is opened (default is 0).Methods inherited from class com.northconcepts.datapipeline.core.AbstractReader
getFieldNames, getLastRow, getStartingRow, isFieldNamesInFirstRow, isSkipEmptyRows, read, readImplMethods inherited from class com.northconcepts.datapipeline.core.DataReader
addLineage, available, getBufferSize, getNestedEndpoint, getNestedReader, getReader, getRootEndpoint, getRootReader, isExhausted, isLineageSupported, isSaveLineage, peek, pop, push, setSaveLineage, skipMethods inherited from class com.northconcepts.datapipeline.core.DataEndpoint
decrementRecordCount, enableJmx, getLastRecord, getRecordCount, getRecordCountAsBigInteger, getRecordCountAsString, incrementRecordCount, isRecordCountBigInteger, resetRecordCount, toStringMethods inherited from class com.northconcepts.datapipeline.core.Endpoint
addElapsedtime, assertClosed, assertNotOpened, assertOpened, finalize, getClosedOn, getDescription, getElapsedTime, getElapsedTimeAsString, getOpenedOn, getOpenElapsedTime, getOpenElapsedTimeAsString, getSelfTime, getSelfTimeAsString, getState, isCaptureElapsedTime, isClosed, isOpen, setCaptureElapsedTime
-
Constructor Details
-
GoogleSheetReader
Creates a reader for the given document, which must be opened by the caller and is not closed by this reader unlesssetAutoCloseDocument(boolean)is enabled.
-
-
Method Details
-
open
Description copied from class:DataEndpointMakes this endpoint ready for reading or writing.- Overrides:
openin classAbstractReader- Throws:
DataException
-
close
Description copied from class:DataEndpointIndicates that this endpoint has finished reading or writing.- Overrides:
closein classDataEndpoint- Throws:
DataException
-
getDocument
-
setAutoCloseDocument
Indicates if the GoogleSheetDocument should be closed when this endpoint is closed. The default isfalse. -
isAutoCloseDocument
public boolean isAutoCloseDocument()Indicates if the GoogleSheetDocument should be closed when this endpoint is closed. The default isfalse. -
getSheetName
-
setSheetName
Sets the name of the sheet to read; when set, it is used instead of the sheet index (default is null). -
getRange
-
setRange
Sets the A1-notation range to read, such asA1:B3orSheet1!A1:B3; a range without a sheet prefix is read from the sheet named or indexed on this reader (default is null for the whole sheet). -
getSheetIndex
public int getSheetIndex() -
setSheetIndex
Sets the 0-based index of the sheet to read when no sheet name or range names one (defaults to 0). -
getStartingColumn
public int getStartingColumn() -
setStartingColumn
Sets the 0-based index of the first column read; earlier columns are skipped (defaults to 0). -
getLineNumber
public long getLineNumber()Returns the 0-based index of the next row to read within the loaded sheet or range. -
setFieldNamesInFirstRow
Description copied from class:AbstractReaderIndicates if the first row holds the field names instead of data (default is false); must be called beforeAbstractReader.open().- Overrides:
setFieldNamesInFirstRowin classAbstractReader
-
setFieldNames
Description copied from class:AbstractReaderSets the names given to each record's fields, taking precedence over names in the first row; must be called beforeAbstractReader.open().- Overrides:
setFieldNamesin classAbstractReader
-
setFieldNames
Description copied from class:AbstractReaderSets the names given to each record's fields, taking precedence over names in the first row; must be called beforeAbstractReader.open().- Overrides:
setFieldNamesin classAbstractReader
-
setStartingRow
Description copied from class:AbstractReaderSets the 0-based index of the first row to read; earlier rows are skipped when the reader is opened (default is 0).- Overrides:
setStartingRowin classAbstractReader
-
setLastRow
Description copied from class:AbstractReaderSets the 0-based index of the last row to read or -1 to read to the end (default is -1).- Overrides:
setLastRowin classAbstractReader
-
setSkipEmptyRows
Description copied from class:AbstractReaderIndicates that rows with only null values should not be returned by the reader (default is false).- Overrides:
setSkipEmptyRowsin classAbstractReader
-
setDescription
Description copied from class:EndpointSets the optional text shown for this endpoint inEndpoint.toString()and exception properties.- Overrides:
setDescriptionin classEndpoint
-
fillRecord
Description copied from class:AbstractReaderPopulates the given record with the next row's values; returns false at the end of the input.- Specified by:
fillRecordin classAbstractReader- Throws:
Throwable
-
addExceptionProperties
Description copied from class:EndpointAdds this endpoint's current state to aDataException. Since this method is called whenever an exception is thrown, subclasses should override it to add their specific information.- Overrides:
addExceptionPropertiesin classAbstractReader
-