Create List Item from CSV

Hey guys,

I prepared several custom lists (testlist 1-6) in SharePoint with following columns: Title, Department, Name.

I also have an CSV-file with multiple columns (Web, List, Title, Department, Name)

Web and List are location indicators for the items. Title, Department and Name are parameters of the item.

How can I realize to create listi tems on the corresponding list from this CSV?

Kind regards,

Tobi

January 13th, 2014 5:20pm


You can use Powershell script to do :

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

http://davidlozzi.com/2012/02/29/loading-sharepoint-lists-from-excel/

might want to read following:

http://community.office365.com/en-us/forums/154/t/10096.aspx


January 13th, 2014 5:43pm

You can develop a tool that reads the CSV file and loops through every line.

For every line get weburl, listname, title, department, name and run the steps listed below:

  1. Get the web
    

If you have the webUrl you can use the code below

using (SPSite site = new SPSite(webUrl))
{
        using (SPWeb web = elevatedsite.OpenWeb())
        {
	
        }
}

2. Get the list

SPList list = web.GetListFromUrl(web.Url + /Lists/ListName/Forms/AllItems.aspx);

3. Creates an item and sets the field values

SPListItem item  = list.AddItem();
item[Title] = title;
item[Department] = department;
item[Name] = name;

4. Updates the item

item.Update();

The same can be achieved with PowerShell by write the logic above in PowerShell script.




Free Windows Admin Tool Kit Click here and download it now
January 13th, 2014 5:46pm

Thanks for your answers! I already know how to create list items from CSV.

But I still have the following problem: 

The items in should be stored in different lists. The corresponding lists are written in the CSV as well. 

So how can I handle that Powershell loops through every line and creates the the items on the right list?


Regards,

Tobi

January 13th, 2014 6:41pm

Hi,

For this new question, I would suggest you post it in a new thread, it would be easier to be disscussed by others and it will benefit other community members who stuck with the same question.

Thanks

Free Windows Admin Tool Kit Click here and download it now
February 5th, 2014 5:20am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics