Home SharePoint 2013 Powershell Import Data from csv to sharepoint 2013 list with special characters
Powershell Import Data from csv to sharepoint 2013 list with special characters
Gowtham
Wednesday, February 25, 2015
Add-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue
############## PARAMETERS ####################
$WebUrl = "Enter the sitecollection url"
$Listname = "Enter the Listname"
#Convert CSV to UTF-8 with special characters
Get-Content E:\Tempfolder\testCSV.csv | Out-File
E:\Tempfolder\testCSV.csv -Encoding utf8
#Get the CSV file and connect to the SharePoint list
$DataSet = import-csv -Delimiter ";" -Path
E:\Tempfolder\testCSV.csv" -Encoding Unicode
######### Add to SPList ########
$spWeb = Get-SPWeb -identity $WebUrl # Get SPWeb
$list = $spWeb.Lists[$Listname] # Get SPList
for($i = 0; $i -le $DataSet.Count; $i++)
{
#Read current row
$row = $DataSet[$i]
$item = $list.Items.Add();
$item["SPColumn1"] = $row.'Column1'
$item["SPColumn2"] = $row.'Column2'
$item["SPColumn3"] = $row.'Column3'
$item["SPColumn_n"] = $row.'Column_n'
$item.Update()
}
1 Comments
Extremely useful information which you have shared here. This is a great way to enhance knowledge for us, and also helpful for us. Thankful to you for sharing an article like this.
ReplyDeleteMexico Export Data