@@ -49,30 +49,56 @@ pipeline ElectricVehiclesPipeline {
4949
5050 block ElectricVehiclesCSVInterpreter oftype CSVInterpreter { }
5151
52+ valuetype ElectricVehicle {
53+ property vin oftype VehicleIdentificationNumber10;
54+ property county oftype text;
55+ property city oftype text;
56+ property state oftype UsStateCode;
57+ property postal oftype text;
58+ property modelYear oftype integer;
59+ property make oftype text;
60+ property model oftype text;
61+ property evType oftype text;
62+ property cafvEligibility oftype text;
63+ property electricRange oftype integer;
64+ property baseMSRP oftype integer;
65+ property legislativeDistrict oftype text;
66+ property dolID oftype integer;
67+ property location oftype text;
68+ property utility oftype text;
69+ property censusTract oftype text;
70+ }
71+
72+ transform ElectricVehicleParser {
73+ from r oftype Collection<text>;
74+ to ev oftype ElectricVehicle;
75+
76+ ev: {
77+ vin: r cellInColumn "VIN (1-10)",
78+ county: asText (r cellInColumn "County"),
79+ city: asText (r cellInColumn "City"),
80+ state: asText (r cellInColumn "State"),
81+ postal: asText (r cellInColumn "Postal Code"),
82+ modelYear: asInteger (r cellInColumn "Model Year"),
83+ make: asText (r cellInColumn "Make"),
84+ model: asText (r cellInColumn "Model"),
85+ evType: asText (r cellInColumn "Electric Vehicle Type"),
86+ cafvEligibility: asText (r cellInColumn "Clean Alternative Fuel Vehicle (CAFV) Eligibility"),
87+ electricRange: asInteger (r cellInColumn "Electric Range"),
88+ baseMSRP: asInteger (r cellInColumn "Base MSRP"),
89+ legislativeDistrict: asText (r cellInColumn "LegislativeDistrict"),
90+ dolID: asInteger (r cellInColumn "DOL Vehicle ID"),
91+ location: asText (r cellInColumn "Vehicle Location"),
92+ utility: asText (r cellInColumn "Electric Utility"),
93+ censusTract: asText (r cellInColumn "2020 Census Tract"),
94+ };
95+ }
96+
97+
5298 block ElectricVehiclesTableInterpreter oftype TableInterpreter {
5399 header: true;
54- columns: [
55- // 4. Here, a user-deifned value type is used to describe this column.
56- // The capital letter indicates that the value type is not built-in
57- // by convention. The value type itself is defined further below.
58- "VIN (1-10)" oftype VehicleIdentificationNumber10,
59- "County" oftype text,
60- "City" oftype text,
61- "State" oftype UsStateCode, // We can just use the element as if it was defined in this file.
62- "Postal Code" oftype text,
63- "Model Year" oftype integer,
64- "Make" oftype text,
65- "Model" oftype text,
66- "Electric Vehicle Type" oftype text,
67- "Clean Alternative Fuel Vehicle (CAFV) Eligibility" oftype text,
68- "Electric Range" oftype integer,
69- "Base MSRP" oftype integer,
70- "Legislative District" oftype text,
71- "DOL Vehicle ID" oftype integer,
72- "Vehicle Location" oftype text,
73- "Electric Utility" oftype text,
74- "2020 Census Tract" oftype text,
75- ];
100+ columns: ElectricVehicle;
101+ parseWith: ElectricVehicleParser;
76102 }
77103
78104 // 5. This block describes the application of a transform function
@@ -81,9 +107,9 @@ pipeline ElectricVehiclesPipeline {
81107 // by the "use" property.
82108 block ElectricRangeTransformer oftype TableTransformer {
83109 inputColumns: [
84- "Electric Range "
110+ "electricRange "
85111 ];
86- outputColumn: "Electric Range (km)";
112+ outputColumn: "electricRange (km)";
87113 uses: MilesToKilometers;
88114 }
89115
0 commit comments