1 Replies - 287 Views - Last Post: 27 October 2013 - 11:18 AM Rate Topic: -----

#1 jeansymolanza  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 77
  • Joined: 20-February 08

Poweshell - importing data from a csv file

Posted 27 October 2013 - 10:35 AM

I'm currently having issues importing data from a csv file.

The csv file has three columns: appname, location, lob, os and 562 entries in total.

Powershell only seems to pick up 274 entries.

Is there anything I'm doing wrong?

    Import-CSV applications.csv | ForEach-Object {
        $appname = $_.appname.ToLower()
        $os = $_.os.ToLower()
        $lob = $_.lob.ToLower()
        $location = $_.location.ToLower()
        
        if ($Applications.Keys -notcontains $appname) {
            $WindowsOS=@{}
            
            # hashtable for windows xp and windows 7 applications
            $WindowsOS["windows xp"]=@{}
            $WindowsOS["windows 7"]=@{}
            $Applications[$appname]=$WindowsOS
        } 
       
        if ($Applications[$appname][$os].Keys -notcontains $lob) {
            $Applications[$appname][$os][$lob]=@()
        }
        
        if ($Applications[$appname][$os][$lob].Keys -notcontains $location) {
            $Applications[$appname][$os][$lob]+=$location
        }
    }
    
    $Applications


Is This A Good Question/Topic? 0
  • +

Replies To: Poweshell - importing data from a csv file

#2 andrewsw  Icon User is offline

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3371
  • View blog
  • Posts: 11,420
  • Joined: 12-December 12

Re: Poweshell - importing data from a csv file

Posted 27 October 2013 - 11:18 AM

Is it picking up the first 274 lines/entries? That is, not skipping some.

Is there anything on or around line 275 that is different to the previous lines?

Posting a sample of the csv-text would help. Posting within quote-tags might help to preserve some formatting.

This post has been edited by andrewsw: 27 October 2013 - 11:19 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1