none
Missing '=' operator after key in hash literal. RRS feed

  • Question

  • $filedata = Get-Content $pwd\Result.csv
    $asObject = ForEach($singlerow in ($filedata | Select-Object -Skip 0))
    {

    $.singlerow = $.singlerow -split ',(,)'

    [pscustomobject][ordered]@{
            Number of total .rslt: = $singlerow[0]
            Number of total .dx: = $singlerow[1]
            Number of total .rx = $singlerow[2]
            Number of total .pdf = $singlerow[3]
        }
    }
    }

    What's getting wrong in this code? m not able to figure it out.

    Giving me the exception Missing '=' operator after key in hash literal.

     


    • Edited by 12 34 Thursday, February 11, 2016 10:36 AM
    Thursday, February 11, 2016 10:36 AM

Answers

  • Ah, it's because you've got spaces in your initial terms.

    [pscustomobject][ordered]@{
            "Number of total .rslt:" = $singlerow[0]
            "Number of total .dx:" = $singlerow[1]
            "Number of total .rx" = $singlerow[2]
          "Number of total .pdf" = $singlerow[3]
        }
    Thursday, February 11, 2016 10:53 AM

All replies

  • Semi colons at the end of each line?
    Thursday, February 11, 2016 10:46 AM
  • Thankyou

    Sorry, it's giving the same exception.




    • Edited by 12 34 Thursday, February 11, 2016 10:52 AM
    Thursday, February 11, 2016 10:50 AM
  • Ah, it's because you've got spaces in your initial terms.

    [pscustomobject][ordered]@{
            "Number of total .rslt:" = $singlerow[0]
            "Number of total .dx:" = $singlerow[1]
            "Number of total .rx" = $singlerow[2]
          "Number of total .pdf" = $singlerow[3]
        }
    Thursday, February 11, 2016 10:53 AM
  • This is what you want.

    Import-Csv  $pwd\Result.csv -header 'Number of total .rslt','Number of total .dx','Number of total .rx'.'Number of total .pdf' | 
         Format-List


    \_(ツ)_/



    • Edited by jrv Thursday, February 11, 2016 11:29 AM
    Thursday, February 11, 2016 11:29 AM