Last active
December 18, 2020 00:38
-
-
Save winslowdibona/70591003973a98f030c86a89947d3a28 to your computer and use it in GitHub Desktop.
csv-etl example
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
rules: | |
- | |
target: OrderId | |
type: Calculation | |
input_type: Integer | |
output_type: Integer | |
source: Order Number | |
- | |
target: OrderDate | |
type: Calculation | |
input_type: Integer | |
output_type: Date | |
source: | |
- Day | |
- Month | |
- Year | |
operations: | |
- "datetime(s[2], s[1], s[0])" | |
- | |
target: ProductId | |
type: Calculation | |
input_type: String | |
output_type: String | |
source: Product Number | |
- | |
target: ProductName | |
type: Calculation | |
input_type: String | |
output_type: String | |
source: Product Name | |
operations: | |
- "s.title()" | |
- | |
target: Quantity | |
type: Calculation | |
input_type: Decimal | |
output_type: Decimal | |
source: Count | |
- | |
target: Unit | |
type: Static | |
input_type: String | |
output_type: String | |
source: kg |
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
pip install csv-etl | |
# result as json | |
csv-etl ./config.yaml ./test_data.csv | |
# result as csv | |
csv-etl ./config.yaml ./test_data.csv --format=csv | |
# result as written to csv file | |
csv-etl ./config.yaml ./test_data.csv --format=csv --outfile=./result.csv |
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
Order Number | Year | Month | Day | Product Number | Product Name | Count | Extra Col1 | Extra Col2 | Empty Column | |
---|---|---|---|---|---|---|---|---|---|---|
1000 | 2018 | 1 | 1 | P-10001 | Arugola | 5,250.50 | Lorem | Ipsum | ||
1001 | 2017 | 12 | 12 | P-10002 | Iceberg lettuce | 500.00 | Lorem | Ipsum |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment