none
read csv file Orchestrator (semicolun) RRS feed

  • Question

  • I am using Orchestrator to use a csv file as input file.
    This works fine with the code below, where the csv file has comma separated values.

    But now I have an input file of which the values are separated by semicolun's (;)

    The content below works perfectly, but what do I need to adjust (in the $-part) to read the semicolun values ?

    I changed some of the comma's to semicolun's, but it didn't work

    ---------------------------------------------------------
    csv file

    name,first,last
    Doe,John,Doe
    ---------------------------------------------------------

    $ArrayList = @()

    "Line text from "Read Line".Split("'`n") | ForEach {
       $ArrayList += "$_"
    }
    ---------------------------------------------------------

    $name = "[Field({ArrayList from "GetRecords"},',',1)]"
    $first = "[Field({ArrayList from "GetRecords"},',',2)]"
    $last = "[Field({ArrayList from "GetRecords"},',',3)]"

    Wednesday, December 16, 2015 11:43 AM

Answers

  • May be this?

    $ArrayList = @()

    "Line text from "Read Line".Split("'`n") | ForEach {
       $ArrayList += "$_".Replace(';',',')
    }

    Wednesday, December 16, 2015 12:43 PM

All replies

  • Hi, why do not use Import-CSV? Like this

    $Name = (Import-CSV "FileName" -Delimeter ';').Name


    Wednesday, December 16, 2015 12:13 PM
  • I am now using the Read-Line activity to read the csv file.

    The next step is the $Array script to read all records and then the process records step is the $name ... command.

    How does your proposal fit in this process ?

    Since the above mentioned steps and scripts work perfectly for a csv file with comma separated values, I suppose it should be able to adjust it for reading a file with semicolon separated values.

    unfortunately I didn't find out yet what character to adust, it should be some character at the end of this line, where you would expect that one of the comma's should be replaced with a semicolon.

    $name = "[Field({ArrayList from "GetRecords"},',',1)]"


    • Edited by Piet111 Wednesday, December 16, 2015 12:29 PM
    Wednesday, December 16, 2015 12:17 PM
  • May be this?

    $ArrayList = @()

    "Line text from "Read Line".Split("'`n") | ForEach {
       $ArrayList += "$_".Replace(';',',')
    }

    Wednesday, December 16, 2015 12:43 PM
  • Wednesday, December 16, 2015 1:48 PM
    Moderator