Share via


Automatically importing a csv file to a SharePoint list

Question

Friday, January 23, 2015 7:46 PM

I get a csv file from a program every day. Instead of copying and pasting the data into a SP list, is it possible to have the file copied to a location and SP import it on a regular basis? I would avoid the manual copy paste as well as I wouldn't have to be present to do the conversion.

All replies (6)

Monday, January 26, 2015 1:46 PM âś…Answered

See this YouTube video -

 Hope they will help

Please 'propose as answer' if it helped you, also 'vote helpful' if you like this reply.


Friday, January 23, 2015 8:05 PM

Hi

Here is the powershell script which you can use

function Add-CsvDataToList([Microsoft.SharePoint.SPWeb]$web, [string] $listName, [string] $csvPath) { 
$list = $web.Lists.get_Item($listName) 
Import-Csv $csvPath | ForEach-Object { 
$csvRow = $_ 
$newItem = $list.Items.Add() 
Get-Member -InputObject $csvRow -MemberType NoteProperty | ForEach-Object { 
$property = $_.Name 
$newItem.set_Item($property, $csvRow.$property) } $newItem.Update()
 }
 }

Following are the links for reference

http://blog.brianfarnhill.com/2012/07/populate-a-sharepoint-list-with-items-in-a-csv-file-using-powershell

http://blogs.technet.com/b/stuffstevesays/archive/2013/06/07/populating-a-sharepoint-list-using-powershell.aspx

https://ravendra.wordpress.com/uploading-csv-excel-data-into-sharepoint-list/

Please 'propose as answer' if it helped you, also 'vote helpful' if you like this reply.

Amit Kotha


Friday, January 23, 2015 8:30 PM | 1 vote

You have to a custom automation as there is no OOTB way.

  • Option 1: Run a powershell script by schedule task (As amit says)
  • Option 2: Create timer Job which will read HTML and appens in list
  • Option 3: Create SSIS package and read excel to append in List

I will prefer Option 3 personally as it is no code solution.

Please 'propose as answer' if it helped you, also 'vote helpful' if you like this reply.


Monday, January 26, 2015 9:11 AM

Hi JLarr,

If required, also you may want to run the PowerShell script ps1 file on a certain time automatically to import the csv data into SharePoint list using Windows server "Task Schduler", please see more about how to use Task Schduler to run PowerShell script from below articles.

http://get-spscripts.com/2011/01/running-sharepoint-powershell-script.html

http://blogs.technet.com/b/meamcs/archive/2013/02/23/sharepoint-2013-backup-with-powershell-and-task-scheduler-for-beginners.aspx

Thanks,
Daniel Yang
Forum Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact [email protected].

Daniel Yang
TechNet Community Support


Monday, January 26, 2015 12:52 PM

Since I don't have a lot of resources, is there a link for option 3? I'll see if I can find one myself. But if you have a better one, I'm all ears.


Monday, January 26, 2015 1:38 PM

try these links:

http://blogs.technet.com/b/meamcs/archive/2013/02/23/sharepoint-2013-backup-with-powershell-and-task-scheduler-for-beginners.aspx

http://blog.brianfarnhill.com/2012/07/populate-a-sharepoint-list-with-items-in-a-csv-file-using-powershell

https://ravendra.wordpress.com/uploading-csv-excel-data-into-sharepoint-list/

Please mark as answer if you find it useful else vote for it if it is close to answer..happy sharepointing