How do I import csv file into a SharePoint list?

I am trying to use a PowerShell script to load data into a SharePoint list from a csv file. When I run my code, it seems to go through the process of loading the data into the list. However when I go to my list, all I see is "System.Object[]" displayed
in the first column of all my rows with no other data displayed. When I check my csv file, I see a ton of data (several rows and columns) but that is not being moved to my SharePoint list. This is what my script looks like
if((Get-PSSnapin | Where {$_.Name -eq “Microsoft.SharePoint.PowerShell”}) -eq $null) {
Add-PSSnapin Microsoft.SharePoint.PowerShell
$web = Get-SPWeb http://link to web
$list = $web.lists["List Name"]
$recordsNumber = 0
foreach($i in Import-CSV myCSVFile.csv)
$new = $list.Items.Add()
$new["Title"] = $i.Title,
$new["FirstName"] = $i.FirstName,
$new["LastName"] = $i.LastName
$new.Update()
$recordsNumber++
"Added " + $recordsNumber.ToString() + " records."
"Done. Press any key to continue..."
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
Any ideas on how to fix this, and get my list populated with data?

if ( (Get-PSSnapin -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) -eq $null )
Add-PsSnapin Microsoft.SharePoint.PowerShell
$host.Runspace.ThreadOptions = "ReuseThread"
#Open SharePoint List
$SPServer=http://SOMESERVER
$SPAppList="/Lists/List Name/"
$spWeb = Get-SPWeb $SPServer
$spData = $spWeb.GetList($SPAppList)
$InvFile="myCSVFile.csv"
# Get Data from Inventory CSV File
$FileExists = (Test-Path $InvFile -PathType Leaf)
if ($FileExists) {
"Loading $InvFile for processing..."
$tblData = Import-CSV $InvFile
} else {
"$InvFile not found - stopping import!"
exit
# Loop through Applications add each one to SharePoint
"Uploading data to SharePoint...."
foreach ($row in $tblData)
"Adding entry for "+$row."Application Name".ToString()
$spItem = $spData.AddItem()
$spItem["Title"] = $row."Title".ToString()
$spItem["FirstName"] = $row."FirstName".ToString()
$spItem["LastName"] = $row."LastName".ToString()
$spItem.Update()
"Upload Complete"
$spWeb.Dispose()
Link
Please 'propose as answer' if it helped you, also 'vote helpful' if you like this reply.

Similar Messages

  • How to gracefully import CSV files into Numbers.app v3?

    I've posted this as a question at Stack Exchange, also…
    I have a process, which has worked faithfully for years in Numbers '09, whereby I download my Bank account data in CSV format, then drag that data directly into my Numbers sheet (after creating an appropriate number of blank rows).
    This no longer works, and I can't find an option to import csv! A help search within numbers for 'csv' returns a single result which describes exporting.
    I've tried the old method, no dice. Also, the menu option: Insert > Choose… doesn't permit .csv to be selected.
    At the moment, my workaround is:
    drag the CSV onto the Numbers dock or task-switcher icon to create a temp sheet
    select and copy the content
    paste-and-match-format into my desired location
    close don't save the temp file
    Doe anyone know a better way? A hack or hidden flag I can toggle to get the old functionality back?

    Hi David,
    Your CSV file seems to be a hybrid (mongrel). Where did it originate?
    Regions that use a full-stop (.) as as the decimal point use comma (,) as the separator in CSV files. But wait, there is more! CSV can also mean Character Separated Values, and that character could be semi-colon (;) or Tab.
    Are you able to open that file in TextEdit or Pages or Word and replace the separator? Replacing ; with Tab may work.
    I must admit that I have never had trouble with CSV opening in Numbers with a double-click in Finder. For example, my bank statements download with what works in my Region (strings enclosed with "double quotes" and columns separated by commas and numbers with a full-stop as the decimal point. Maybe I am just lucky. .
    Regards,
    Ian.

  • Looking for a Notes app that I can import CSV files into?

    As the title says, I'm looking for a good notes application for my iPhone that I can import CSV files into. I have tried both Appigo and Notespark, but I can't easily scroll through them, as I have 2,000+ notes. Is there any app that I can import my notes into and also scroll through quickly? I'd like something that works similarly to how you scroll through songs on the iPhone/iTouch, with the column on the right where you can skip to songs (notes, in this case) that start with a certain letter.
    Thanks!

    Hi Tx Tar Heel,
    I've been using Office2HD: https://itunes.apple.com/us/app/office2-hd/id364361728?mt=8
    Its cheaper than Numbers and it also works for Word and PowerPoint files too. I like the Dropbox integration. I can start on my Office docs (Word, Excel, PowerPoint) in the office and then edit those files with Office2HD when I'm out of the office. Files saves right back to Dropbox so that when I get back to the office the files are already updated. Not bad for a $7.99 app!
    Hope this helps!
    ~Joe

  • I shot video on a Panasonic P2 and I'm trying to import the MXF files to Final Cut Pro but when I try to import, the only thing that imports is a blurry image of each clip. There's no audio and no video...how can I import MXF files into Final Cut Pro?

    I shot video on a Panasonic P2 and I'm trying to import the MXF files to Final Cut Pro but when I try to import, the only thing that imports is a blurry image of each clip. There's no audio and no video...how can I import MXF files into Final Cut Pro?

    at the end, you say "import preferences", which program are you describing?
    So im safer using footage that is remotely being pulled from iphoto...
    vs
    using footage that is imported into FCP from imovie?
    Is there anything i can do in fcp to make this footage more reliable or safer or more stable as i pull remotely from iphoto?
    All the footage, and all the libraries to all programs, or on a new pegasus 12tb raid 5 setup fyi.

  • How can I import vob files into imovie 09?

    how can I import vob files into imovie 09? i have some home movies on dvd that i want to edit.

    You might want to look at this one too.  Very easy to use and it doesn't require the Apple MPEG-2 playback component.
    http://www.dvdxdv.com/NewFolderLookSite/Products/DVDxDV.overview.htm

  • How can i import mpeg files into iMovie?

    how can i import mpeg files into iMovie?

    Where are your MPEG stored?
    I have hundreds of old MPEGs stored in my nexternal drive, but unfortunatly i was not able import them into iMovie. I did the following trick: I created a new set of a folder and subfolder and called it "Virtual_CAM/DCIM" and saved it on my desktop. Then went to Disk Utilities>File Menue>New>Disk Image from Folder. Then selected the folder on my desktop and clicked enter. I moved the .dmg file to my external (or just keep it on your desktop). I clicked on the .dmg file. It shoud be visible on the Finder. Open your Imovie and import as you do from your camera.

  • I need to know how best to import .mod files into elements 7

    I need to know how best to import .mod files into elements 7

    lornamarieslade
    Are you working with .mod standard or widescreen?
    If .mod standard, less problematic. The file just might import without issue. Worst case would probably be changing the file extension from .mod to .mpg just prior to import.
    Now .mod widescreen is another story that revolves around maintaining the 16:9 flag that scretches the video for display after encoding. Some have said that the 16:9 flag is lost in the transfer to computer; some say certain editors such as Premiere Elements just cannot read/recognize the flag. Whatever the case this is what you should consider in your Premiere Elements 7 Windows.
    a. If you need to rename the file extension from .mod to .mpg, do so prior to import.
    b. Import the .mod or .mpg counterpart into your Premiere Elements 7 project using the project preset NTSC or PAL DV Widescreen (NTSC or PAL depends on your location of interest). You will probably see that the video does not fill the space in the Edit Mode Monitor (you will probably see standard 4:3 looking image rather than widescreen 16:9 looking image).
    c. Right click the file in the Project media area, select Interpret Footage, and, in the Interpret Footage Dialog/Pixel Aspect Ratio section, dot the Conform To: and change the setting to
    D1/DV NTSC Widescreen 16:9 (1.2)
    or
    D1/DV PAL Widescreen 16:9 (1.422)
    depending on your location of interest.
    A while back there used to be a program called SD Copy that did the job of file name change and adding the 16:9 flag prior to import of the .mod widescreen into Premiere Elements. But, I have lost track of the SD Copy and suspect that is it no longer available. I have dealt with this issue many times at a forum that I formerly frequent. Most have reported back that this workaround worked for them. It is worth a try. I am looking forward to your results.
    If you do opt to upgrade to Premiere Elements 11 Windows (please go tryout before purchase), I am eager to learn how your .mod widescreen is handled by version 11 in your computer environment.
    Thanks.
    ATR
    Add On...I just came across this download for SDCopy. It does not give the appearance of the original the link to which is broken. I have not downloaded and used the following since I do not have any .mod widescreen. So, no guarantees. Please let us know the outcome if you try it if Interpret Footage does not work for you.
    http://paulmcgrath.net/download.php?view.8

  • HT3775 How do I import .mov files into iPhoto, iMovie, iTunes?

    How do I import .mov files into iPhoto, iMovie, iTunes?

    This is just a hunch - are they AVCHD? What type of camera/camcorder are they from?
    http://support.apple.com/kb/HT5409?viewlocale=en_US&locale=en_US
    There are many more hits if you do a search in the forums on those.
    If they are not, then post back with camera info including what it says in the specs about the file forumat it shoots video in.

  • How to read/write .CSV file into CLOB column in a table of Oracle 10g

    I have a requirement which is nothing but a table has two column
    create table emp_data (empid number, report clob)
    Here REPORT column is CLOB data type which used to load the data from the .csv file.
    The requirement here is
    1) How to load data from .CSV file into CLOB column along with empid using DBMS_lob utility
    2) How to read report columns which should return all the columns present in the .CSV file (dynamically because every csv file may have different number of columns) along with the primariy key empid).
    eg: empid report_field1 report_field2
    1 x y
    Any help would be appreciated.

    If I understand you right, you want each row in your table to contain an emp_id and the complete text of a multi-record .csv file.
    It's not clear how you relate emp_id to the appropriate file to be read. Is the emp_id stored in the csv file?
    To read the file, you can use functions from [UTL_FILE|http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/u_file.htm#BABGGEDF] (as long as the file is in a directory accessible to the Oracle server):
    declare
        lt_report_clob CLOB;
        l_max_line_length integer := 1024;   -- set as high as the longest line in your file
        l_infile UTL_FILE.file_type;
        l_buffer varchar2(1024);
        l_emp_id report_table.emp_id%type := 123; -- not clear where emp_id comes from
        l_filename varchar2(200) := 'my_file_name.csv';   -- get this from somewhere
    begin
       -- open the file; we assume an Oracle directory has already been created
        l_infile := utl_file.fopen('CSV_DIRECTORY', l_filename, 'r', l_max_line_length);
        -- initialise the empty clob
        dbms_lob.createtemporary(lt_report_clob, TRUE, DBMS_LOB.session);
        loop
          begin
             utl_file.get_line(l_infile, l_buffer);
             dbms_lob.append(lt_report_clob, l_buffer);
          exception
             when no_data_found then
                 exit;
          end;
        end loop;
        insert into report_table (emp_id, report)
        values (l_emp_id, lt_report_clob);
        -- free the temporary lob
        dbms_lob.freetemporary(lt_report_clob);
       -- close the file
       UTL_FILE.fclose(l_infile);
    end;This simple line-by-line approach is easy to understand, and gives you an opportunity (if you want) to take each line in the file and transform it (for example, you could transform it into a nested table, or into XML). However it can be rather slow if there are many records in the csv file - the lob_append operation is not particularly efficient. I was able to improve the efficiency by caching the lines in a VARCHAR2 up to a maximum cache size, and only then appending to the LOB - see [three posts on my blog|http://preferisco.blogspot.com/search/label/lob].
    There is at least one other possibility:
    - you could use [DBMS_LOB.loadclobfromfile|http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_lob.htm#i998978]. I've not tried this before myself, but I think the procedure is described [here in the 9i docs|http://download.oracle.com/docs/cd/B10501_01/appdev.920/a96591/adl12bfl.htm#879711]. This is likely to be faster than UTL_FILE (because it is all happening in the underlying DBMS_LOB package, possibly in a native way).
    That's all for now. I haven't yet answered your question on how to report data back out of the CLOB. I would like to know how you associate employees with files; what happens if there is > 1 file per employee, etc.
    HTH
    Regards Nigel
    Edited by: nthomas on Mar 2, 2009 11:22 AM - don't forget to fclose the file...

  • How to covert a CSV file into a file of spreadsheet format(staroffice)?

    Hello everybody,
    I want to create a java that can convert CSV file into spreadsheet. But i dont have any idea how to create a Spreadsheet (i just know it have a Binary File format).
    So anyone can give me some reference or program sample, some advises ????
    Pls help
    thx

    Hi
    set the content type as given below and PrintWriter class to write into excel sheet
    response.setContentType("application/x-msexcel");
    response.setHeader("Content-Disposition", "attachment; filename=" + "abc Download" + ".xls");

  • IPhoto:  How can I import pdf files into iPhoto?

    It seemed to work before but I can no longer import pdf files into iPhoto.  What heppened and how can fix it?  Many thanks in advance ... Abe

    Have you tried opening the PDF in Preview and printing using the PDF option selecting save PDF to iPhoto?
    LN

  • How can I import .mts files into Final Cut Studio from my Sony High Def Camcorder

    How can I import .mts files from my Sony High Def camcorder into Final Cut Studio?

    Also see: https://discussions.apple.com/community/professional_applications/search.jspa?pe opleEnabled=true&userID=&containerType=&container=&spotlight=true&q=.mts

  • Best way to import csv file into sql server

    Hello DBAs
    always thankful for your help and one question, what is the best way to import a csv file into sql server ?

    and there is a
    Bulk Insert Task for the Control Flow.
    http://www.youtube.com/watch?v=ACuCU6IqO50
    Please mark the post as answered if it answers your question | My SSIS Blog:
    http://microsoft-ssis.blogspot.com |
    Twitter

  • How can I import a file into my Windows Phone 8.1RT App?

    Hi All,
    I'm running into a bit of an issue associating my app with a custom file type.  Users create a file using my app and upload it to their OneDrive for sharing.  So I then want to give the users the ability to download the file from a share link and
    have that file open automatically in my app.  I've got the appropriate declarations set and file type associations, but I'm getting a file access exception when I try to open the file.  Whats the best way to import a file into my app?  Here's
    the code I've got so far:
    protected override async void OnFileActivated(FileActivatedEventArgs args)
    var path = args.Files[0].Path;
    var name = args.Files[0].Name;
    StorageFile newFile = await StorageFile.GetFileFromPathAsync(path);
    await newFile.CopyAsync(ApplicationData.Current.LocalFolder, name.Substring(0, name.Length - 4));
    The path comes back as
    C:\Data\Users\DefApps\APPDATA\Local\Packages\microsoft.microsoftskydrive_8weke\LocalState\OpenWithTempFolder\e68c261-db3b-472d-a8b7-93427450\File Name.extension
    and the exception is
    Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
    Clearly I'm trying to access the file in an inappropriate way, so what's the best way to get the file into my app's local storage?

    You have the StorageFile in arg.Files[0] already. Just use that rather than getting its path and then trying to create a new StorageFile from it.
    var path = args.Files[0].Path; // <= Path is unnecessary and unhelpful
    var name = args.Files[0].Name;
    await args.Files[0].CopyAsync(ApplicationData.Current.LocalFolder, name.Substring(0, name.Length - 4));
    See my blog entry Skip the path: stick to the StorageFile for more details.

  • How can I import VLC files into quicktime?

    I'd like to be able to import some files into Quicktime from VLC. Thanks. David

    MPEG Streamclip and the MPEG-2 Playback Component should work to demultiplex and convert VOB files. The Help menu in MPEG Streamclip should have complete instructions. You could also look into DVDxDV or Cinematize.

Maybe you are looking for