Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

knowing that is possible in PS, exporting SPList items to PS objects(link1 link2) what is the best way, to go into the other way: Create/Update an SPList from an exported csv or format-table.

share|improve this question
add comment

2 Answers 2

There are 3rd party tools that can automate the update process (only changed items updated, so you can add workflows or attachments).

See here for step-by-step guide: http://www.layer2.de/en/community/FAQs/BDLC/Pages/How-to-connect-text-file-to-sharepoint-list.aspx

share|improve this answer
    
Thanks a lot for the reply, but actually is not a complex PS script to do that. I just wanna know the best way to go. –  fallout Jun 29 '12 at 7:37
add comment
up vote 1 down vote accepted

After creating manually an list based on or csv template via UI...

#get data
$csv = Import-Csv ‘C:\MyData.csv‘
#get list
$web = Get-SPWeb -identity “MyTargetListURL”

foreach ($row in $csv) {
    #Check for existing item
    $SPItem = $SPList.Items | Where { $_["ItemId"] -eq $row.ItemId } 

    If ($SPItem -ne $null) { 
        $SPItem["ColumnNumberType"] = [System.Convert]::ToInt32($row.ColumnNumberType)
        $SPItem["Column with special-chars"] = $row."Column with special-chars"
        #rest of fields

        $SPItem.Update() 
    } 
    Else { 
        $SPNewItem = $SPList.Items.Add() 
        $SPNewItem["ItemId"] = $row.ItemId 
        #rest of fields

        $SPNewItem.Update() 
    } 
 }
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.