Forum Discussion

philliperamos's avatar
philliperamos
Contributor
6 years ago
Solved

Read a CSV file from the Right to Left

Good day community.
I have a CSV file, see attached, which I would like to pick up the last three fields from the right as their own fields, and the rest of the record/line as a “value” field.
sampleData.txt (80 Bytes)

So basically, the output should be
[value] [row] [pipeID] [date]
where is the remainder of the data in the row.

Is this possible?
Thanks

  • Hi Philliperamos,

    I created a pipeline that will keep the last 3 columns as it is and the rest of the row values will be concatenated under the value field. 
    

    Here I am attaching pipeline and sample data file.
    Hope this is what you are required.

    Dynamic_csv_column_change_2019_11_14.slp (10.3 KB)
    sample.txt (231 Bytes)

5 Replies

  • Hi Philliperamos,

    I created a pipeline that will keep the last 3 columns as it is and the rest of the row values will be concatenated under the value field. 
    

    Here I am attaching pipeline and sample data file.
    Hope this is what you are required.

    Dynamic_csv_column_change_2019_11_14.slp (10.3 KB)
    sample.txt (231 Bytes)

    • philliperamos's avatar
      philliperamos
      Contributor

      @nsingam Thanks for this.
      I forgot to mention that the number of columns can change.
      So one file could have 10 columns, another file could have 7, but the last 3 columns would always be ROW, PIPEID and DATE.
      Hence why I wanted to be able to read from right to left.

      • nsingam's avatar
        nsingam
        Employee

        @philliperamos, I am not hardcoded anything in that pipeline. It will work for any no of columns in your CSV file. If for any reason the last 3 columns are different than ROW, PIPEID, DATE then those new columns will be keep as it is and these columns will come under value.

    • philliperamos's avatar
      philliperamos
      Contributor

      @nsingam it works great! Thanks!

      So my file doesn’t have header info, so now I’m just trying to set a header name to fieldX , fieldY and fieldZ

      Thanks again!