Manipulate Date Strings
- 23 Dec 2022
- 1 Minute to read
- Print
- DarkLight
Manipulate Date Strings
- Updated on 23 Dec 2022
- 1 Minute to read
- Print
- DarkLight
Article summary
Did you find this summary helpful?
Thank you for your feedback
Goal: Join two flat files that include date strings into one file.
High-level Task: Perform a join between SKUSales_Quantity.csv
and SKUSales_Revenue.csv
. Join on the "SKU" field and a date field. Then join that output against SKUDescr.csv
on "SKU". Export to flat file.
Detailed Task:
- Create a new flow.
- Add a
Flat File
source node to the canvas. Open theSKUSales_Quantity.csv
file. - Under the
Data Type Assignment
tab, make sure the "SKU" field is the String data type, as well as any date fields (Date, Day, Month, Year). - Repeat step 2 and 3 for the
SKUSales_Revenue.csv
andSKUDescr.csv
files. - Add a
Derive
node to the canvas. Attach theSKUSales_Quantity
flat file source node to it. - Configure the Derive node with the following script to take the 3 source date fields (Day, Month, Year) and output a single Date field.
tmp = row.get('Year') + "-" + row.get('Month') + "-" + row.get('Day');
tmp;
- Add a
Filter
node to the canvas. Remove the Day, Month and Year fields from the output. Rename the derived date field to "Date". - Add a join node to the canvas, and attach the two brances that begin with the
SKUSales_Quantity.csv
andSKUSales_Revenue.csv
nodes. - Configure the
Join
node to join on the "SKU" and "Date" fields. - Repeat steps 8 and 9 for the Join node from the previous step, and the
SKUDescr.csv
node. - Attach this node to a
Flat File
export node. Configure to export to `JoinOutput.csv'.
Was this article helpful?