I have to compare the whole CSV file with SharePoint list items to get the result either SP list items and CSV items are same/equal or not and then do the CRUD operation on SP list to maintain the balanced csv items and SP list items. Thanks in Advance.

  • what is your question? what did you try so far? – Gwny Aug 13 '15 at 8:13
  • I have to compare the csv item with the SP list-item and then if the csv item does not available in the list then need to add that item to list and if list contains more items than the CSV items then need to delete SP list-items. If some changes are thre then need to update the List-item. – Ram Aug 13 '15 at 10:58
  • so start scripting then :) – Gwny Aug 13 '15 at 11:28
  • Hello Gwny Thanks !!! I'd done with my task and used this approch to reach the goal. foreach ($row in $csv) { $CSVid = $row.ID [Microsoft.SharePoint.Client.List]$list = $web.Lists.GetByTitle($listName) $items = $list.GetItemById($CSVid) $context.load($items) try { $context.ExecuteQuery(); } catch { $ErrorMessage = $_.Exception.Message } Is it fine or have some another way to do the same ?? – Ram Aug 14 '15 at 5:11
  • no I think this is fine so far. now you need the part with comparing your fields and updating them – Gwny Aug 14 '15 at 6:41

Create a powershell script which reads the csv as input. Get the List items by id and check if they are equal to the information from your csv. If not, make an update on the item.

Do this for every item. If you need some powershell sharepoint references: http://www.itunity.com/article/completing-basic-operations-sharepoint-csom-api-powershell-1278


I'd done with this code

foreach ($row in $csv) 
    $CSVid = $row.ID
    [Microsoft.SharePoint.Client.List]$list = $web.Lists.GetByTitle($listName)
    $items = $list.GetItemById($CSVid)
    $ErrorMessage = $_.Exception.Message 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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