ETL: Import a list of files
This job iterates over groovy-defined collection of sheets, queries all of them with excel driver and writes a JOB_LOG entry.
<!DOCTYPE etl SYSTEM
"https://scriptella.org/dtd/etl.dtd"
>
<etl>
<description>Import multiple excel sheets</description>
<properties>
file=C:/Data/data.xlsx
</properties>
<connection id=
"groovy"
driver=
"script"
>language=groovy</connection>
<connection id=
"logger"
driver=
"log"
>
level=WARN
</connection>
<connection id=
"excel"
driver=
"excel"
>
format=XLSX
</connection>
<!-- Define multiple sheets -->
<!-- And iterate over them -->
<!-- Note: query.next() have to be called in order to move to nested queries -->
<query connection-id=
"groovy"
>
<![CDATA[
def sheets = [
"Sheet1"
,
"Sheet2"
,
"Sheet3"
]
for
(sheet in sheets) {
etl.globals[
'sheet'
] = sheet
query.next()
}
]]>
<query connection-id=
"excel"
>
path=$file
sheet=${etl.globals[
'sheet'
]}
skip_rows=
1
num_columns=
15
escapeChars='"
<script connection-id=
"logger"
>
Imported: $row.A, $row.B
</script>
</query>
</query>
</etl>