You can import any valid CSV file through this process, and infact, it would work with any data format parseable in .NET - LINQPad provides a full scriptable .NET environment.
Setting up LINQPad
You'll need to install the Umbraco LINQPad driver so that your local LINQPad can connect to your Umbraco installation. Note that you can only connect to a local Umbraco installation, not a copy running on a remote server. You'll have to deploy your data using an Umbraco package.
Now, you should be able to follow Shannon's documentation to get LINQPad setup (taken from the README.md in the GitHub repository)
- In LinqPad, Click "Add Connection"
- Click "View more drivers"
- Select "Browse"
- Add the
UmbracoLinqPad.lpxfile that you've downloaded
- Choose your Umbraco installation root folder
LinqPAD should then have a connection available for your local Umbraco installation, as shown in the screenshot above.
Writing the Import Script
You'll have to write a little custom .NET code in LINQPad to take your CSV file and create the content nodes in Umbraco using the Umbraco API (specifically the content service).
LINQPad provides a full scriptable .NET environment for you to play with. If you've ever done this kind of thing in .NET or worked with LINQPad before, you should be able to improvise.
Though I can't provide a one-size-fits-all solution here, here's a little example code to get you started. Playing with code and your particular CSV file's schema should yield some quick results for you.
Make sure the "language" is set to "C# Program" in the dropdown list at the top of the editor in LINQPad. This will enable you to write a full program instead of a single C# statement inside LINQPad.
Deploying from your local Umbraco to a live environment
Now, because LINQPad can't connect to a live Umbraco environment, you'll have to deploy the new content nodes you've created to your live environment manually. I did this with a package.
1) Open your local Umbraco backoffice. Expand Developer > Packages
2) Right-click on "Created Packages" and click "Create Package". Fill in the package meta-data like Name, Version, License, etc. (There are required fields)
3) Select the content nodes you'd like to deploy in the right-hand pane.
- Make sure you include any document types the new content nodes depend on when you're creating the package.
4) Click "save", and then click "publish"
5) A download link will now be available in the "Package Properties" tab. Download the package and remember where you left it.
Installing the package on the server
This should be as easy as installing any other package.
1) Go to the backoffice in your live environment and expand Developer > Packages
2) Click on "Install Local Package" and follow the on-screen instructions
This process is very flexible and has allowed me to import a diverse range of information into Umbraco. There are some drawbacks, however:
Umbraco LINQPad driver has Certain Limitations
The Umbraco LINQPad driver is very handy, but certain parts of the Umbraco API depend on a WebContext and HTTP/Web Server environment which the LINQPad driver cannot provide.
The Umbraco Packaging Process is Slow and Unreliable with Large Amounts of Data
I think my package was on the brink of being too big, because the package install and content publish process took aaages. I did think it started hanging at one point and refreshed the screen, but the install and publish process relies on the browser session not being refreshed halfway through.
Thanks for reading! If you enjoyed this post and would like to get in touch, find me on twitter @glcheetham.