forked from jvalue/made-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Srinivas Seema
committed
Nov 29, 2023
1 parent
a73841a
commit 5bc579a
Showing
1 changed file
with
110 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
pipeline TrainStopsPipeline { | ||
// Define the pipeline execution order | ||
TrainStopsCSVExtractor -> TrainStopsTextFileInterpreter -> TrainStopsCSVInterpreter -> TrainStopsTableInterpreter -> SQLiteLoader; | ||
//-> ConvertCommaToDecimal | ||
//-> ValidateData | ||
// -> SQLiteLoader | ||
// Extract data from CSV file using semicolon separator | ||
block TrainStopsCSVExtractor oftype HttpExtractor { | ||
url: "https://download-data.deutschebahn.com/static/datasets/haltestellen/D_Bahnhof_2020_alle.CSV"; | ||
} | ||
|
||
block TrainStopsTextFileInterpreter oftype TextFileInterpreter { } | ||
|
||
|
||
block TrainStopsCSVInterpreter oftype CSVInterpreter { | ||
delimiter: ";"; | ||
} | ||
|
||
|
||
//Status column is ignored | ||
block TrainStopsTableInterpreter oftype TableInterpreter { | ||
header: true; | ||
columns: [ | ||
"EVA_NR" oftype integer, | ||
"DS100" oftype ValidTextType, | ||
"IFOPT" oftype IFOPTType, | ||
"NAME" oftype ValidTextType, | ||
"Verkehr" oftype verkehrType, | ||
"Laenge" oftype LaengeType, | ||
"Breite" oftype BreiteType, | ||
"Betreiber_Name" oftype ValidTextType, | ||
"Betreiber_Nr" oftype integer | ||
]; | ||
} | ||
|
||
|
||
|
||
// Load data into SQLite database | ||
block SQLiteLoader oftype SQLiteLoader { | ||
table: "trainstops"; | ||
file: "./trainstops.sqlite"; | ||
} | ||
|
||
valuetype verkehrType oftype text { | ||
constraints: [ | ||
valid_verkehr, notEmpty | ||
]; | ||
} | ||
|
||
valuetype ValidTextType oftype text { | ||
constraints: [ | ||
notEmpty | ||
]; | ||
} | ||
|
||
|
||
valuetype LaengeType oftype decimal { | ||
constraints: [ | ||
validLaenge | ||
|
||
]; | ||
} | ||
|
||
|
||
valuetype BreiteType oftype decimal { | ||
constraints: [ | ||
validBreite | ||
|
||
]; | ||
} | ||
|
||
|
||
valuetype IFOPTType oftype text { | ||
constraints: [ | ||
validIFOPT, | ||
notEmpty | ||
]; | ||
} | ||
|
||
|
||
|
||
//Constriants | ||
|
||
constraint validIFOPT oftype RegexConstraint { | ||
regex: /^[A-Za-z]{2}:\d+:\d+(:\d+)?$/; | ||
} | ||
|
||
constraint notEmpty oftype RegexConstraint { | ||
regex: /^.+$/; | ||
} | ||
|
||
|
||
constraint valid_verkehr oftype AllowlistConstraint { | ||
allowlist: ["FV", "RV", "nur DPN"]; | ||
} | ||
|
||
//lowerBoundInclusive, upperBoundInclusive are true by default. | ||
constraint validLaenge oftype RangeConstraint { | ||
lowerBound: -90; | ||
upperBound: 90; | ||
} | ||
|
||
//lowerBoundInclusive, upperBoundInclusive are true by default. | ||
constraint validBreite oftype RangeConstraint { | ||
lowerBound: -90; | ||
upperBound: 90; | ||
} | ||
|
||
|
||
} |