Hitachi Vantara Pentaho Community Forums
Results 1 to 4 of 4

Thread: How to get the csv filename and use it for value to new field? e.g. 201307Sales.csv

  1. #1
    Join Date
    Aug 2013
    Posts
    6

    Default How to get the csv filename and use it for value to new field? e.g. 201307Sales.csv

    I can successfully get all the data but would like to add new fields YEAR and MONTH based on the filename.

    how can I get it from file name 201307Sales.csv?

  2. #2
    Join Date
    Jun 2012
    Posts
    5,534

    Default

    Add the filename as a field to your row, so that you can extract year and month from there.
    The way to do this depends on the input step you are using and how you provide the filename there.
    So long, and thanks for all the fish.

  3. #3
    Join Date
    Aug 2013
    Posts
    6

    Default

    I am using CSV file input then I ticked the Add filename to result but I dont see the field added.

  4. #4
    Join Date
    Jun 2012
    Posts
    5,534

    Default

    "Add filename to result" adds a filename to a list of filenames, that is meant for house keeping.
    There are a couple of steps to access this list (result filenames), but it doesn't help you here.

    Two input steps are able to read CSV files: CSV Input and Text File Input.
    I use CSV Input only in conjunction with Metadata Injection.
    Text File Input has an "Additional output fields" tab to add the filename to your row.

    With CSV Input it all depends on how your filename is provided, as I wrote earlier.
    For example: If it's a named parameter of your transformation you can add it with a Get Variable step to the row.
    So long, and thanks for all the fish.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.