Manipulate Date Strings
  • 23 Dec 2022
  • 1 Minute to read
  • Dark
    Light

Manipulate Date Strings

  • Dark
    Light

Article summary

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:

  1. Create a new flow.
  2. Add a Flat File source node to the canvas. Open the SKUSales_Quantity.csv file.
  3. 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).
  4. Repeat step 2 and 3 for the SKUSales_Revenue.csv and SKUDescr.csv files.
  5. Add a Derive node to the canvas. Attach the SKUSales_Quantity flat file source node to it.
  6. 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;
  7. Add a Filter node to the canvas. Remove the Day, Month and Year fields from the output. Rename the derived date field to "Date".
  8. Add a join node to the canvas, and attach the two brances that begin with the SKUSales_Quantity.csv and SKUSales_Revenue.csv nodes.
  9. Configure the Join node to join on the "SKU" and "Date" fields.
  10. Repeat steps 8 and 9 for the Join node from the previous step, and the SKUDescr.csv node.
  11. Attach this node to a Flat File export node. Configure to export to `JoinOutput.csv'.

Was this article helpful?