Hitachi Vantara Pentaho Community Forums
Results 1 to 4 of 4

Thread: "inverted" String Cut

  1. #1

    Default "inverted" String Cut

    Hey all!

    I need to transform a fixed length flat file from format A to format B. The main difference is that dates in format A are YYYYMMDD while they're YYMMDD in format B. Great, I thought, I'll read in the whole file row by row and for each row I simply cut out 2 characters every now and then using a String Cut. Result was not what I wanted since String Cut doesn't remove the given substring but passes it on - throwing away the remaining string.
    So my question is: is there a function that does the complete opposite, cut out something in the middle of a string and return the rest of it concatenated? Otherwise, I guess the best is to String Cut all the pieces I need and manually concatenate them just before writing back to a file?!?

    Thanks a lot for your help!

  2. #2
    Join Date
    Nov 2009
    Posts
    688

    Default

    When the input is a date field with format yyyyMMdd then you can change the format with the "Select Values" step where you can change it in the "Meta-data" tab to yyMMdd

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

    Default

    Just don't cut from 0 to 2, use 2 to 8 instead
    So long, and thanks for all the fish.

  4. #4

    Default

    Excuse the late reply (and taking this whole thread up again) but I wanted to let you know how I solved this.

    Johan's suggestion wouldn't work since I don't use any datatype - a fixed length file comes in, each row is read as a string in its entirety, the first 2 characters of a year cut out and the rest set together as a "new" fixed length file.
    But in the end I solved it basically as marabu described. A Row - let's say the following: aaaaaaaabbbbbbbbYYYYMMDDccccccccdddddddd - now gets cut to the following 2 strings:
    aaaaaaaabbbbbbbb
    YYMMDDccccccccdddddddd
    These are then set back together. My initial thought was (technically) to cut away YY with the string aaaaaaaabbbbbbbbYYMMDDccccccccdddddddd remaining instantly - no explicit concatenation or other changes needed. Turns out in the end, the difference of the 2 solutions is minimal...

Tags for this Thread

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.