Drupal 7 Tutorials #47 - Using Feeds to Create Content With CSV Files

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey what's up this is Scott with the level of Tut's and today we're going to take our CSV file that you have made or I have made or whoever and we're going to import it into Drupal and create nodes out of it so to get started you're going to want to have a CSV file mine's really simple has a name column and a body column and basically I have four titles here and for short non sentences and this is going to important to the body and this is going to import in the title and I'm going to show you how to do that using feeds for Drupal okay so the first thing we want to do is we're going to need to create this content type if you've already created your content type great skip ahead a little bit and get to the feed importer section where we're actually creating that but I'm going to create a content type here and just so this is painfully obvious we're going to call this feed so feed title whatever I'm not going to display the I it doesn't really matter I'm not really displaying this stuff anyways okay so I'm going to just save the content type and this is pretty much any content type you know if you're creating one and you have all sorts of fields you can have those fields import just keep on using this example and extend it to your own fields but I'm just going to show for simplicity sake just the title in the body in this one so we don't have to add any fields but if you want to by all means go ahead and try it out okay so now we have this content type now we're going to go to structure feed importers feeds importer I'm sorry and here's the one that we created last time if you haven't just create Adam click add importer and you can name it anything you want I just named this simple CSV and we're going to start at the very top here this basic settings and we're going to go down and we're going to configure this okay so let's click settings here and as you can see it's simple CSV description can be whatever you want if you have lots of feed importers it's going to be helpful to name them and have their descriptions so that you could you know decipher what the different ones are so we're going to be using a standalone content form for this I'm going to click import and it's going to port and we're not going to have this periodically import and it's going to import on submission click Save okay now let's go to change so the fetcher is going to be a file upload and not an HTTP fetcher this is a file I physically have on my on my hard drive here and I'm going to upload it and then click import so we'll click Save here and you'll see now it says file upload down here so we can edit the file upload settings and here are our allowed extensions you can use txt CSV TSV XML OPML we're going to be using a CSV so it's nice and easy ok and the supply path to file or director it directly instance if it's for experts we're not going to do that anyway so basically we're just going to click browse find the file and then get it that way ok so parser this is going to be a CSV parser because we're using a CSV and so this is how feeds knows how to handle this file ok we'll click Save and you'll see that this is now since CSV parser down here we'll go to settings for that ok the default delimiter of course this is a comma separated file so the delimiter is going to be commas however if yours is separated by semicolons or tabs it can also do that ok and this no headers check to see if the does not start off with a header row this does start off with a header row I would recommend it if you're controlling your CSV file just to do it ok so we didn't change anything there so now it's on to processor ok we're going to want to create nodes the nose we're creating our of our feeds and a content type so let's go to settings and what we want to do is we want to update existing nodes so let's say we change something in our feed and then we re-upload the feed it's just going to change that data it says it's a little bit slower but we only have four items in our feed so it's not going to be a big deal and the content type is going to be feed because that's the content type we just made of course it could be anything if you'd like we could even import these into a basic page if we want to do so text format we'll leave it as plain text it's no big deal right now but of course if you you know had a preference for that when you're importing your body text you're going to want to select that here the author we can have this be let's be Scott okay nodes expired never click Save on this and then mapping okay so this is where the headers come into play right so let's select a target here we have our title and we want our title to be the name column so let's use this name right here it will come back to our Drupal and the name of the source field is going to be name and the target is title so now these names are going to get imported into title ok and now we're going to select body and if you look on your spreadsheet it's whatever it is an hour so it's body so it's nice and easy of course it could be anything you wanted and we're going to click Add so keep in mind when you're importing feeds you have to have something that is a unique target usually if you have like an ID or something that's getting imported you're going to use that if we go to our spreadsheet you'll see that all of my feed titles are unique and they're going to be unique for this example so we're just going to say that the title is unique however you're going to want to make sure that whatever you're clicking here is in fact and always going to be unique okay so now let's click Save if we see this legend this just like sort of tells you what each of these targets are of course you can probably figure them out by what they're called but if you need help this is what they are ok so now we have our feed is all ready to go it knows where to look for each of these targets and it knows what to do so now's the fun part now get to import the feed remember at the last video I said that our feed importer would be available at our domain / import okay and here I'll list all of the different feed importers you have sorry this is a little small here this says simple CSV so this is our feed that we created click that and so okay this is going to be easier to read with your theme I should probably just put this on back on garland or whatever for a second or Bartek I guess so import CSV files with one or more of these columns name and body ok the column name is mandatory and could and considered a unique which it is and our file is going to be delimited by commas and again you can check if there's no headers in your particular file here but we have headers so if you had a Google spreadsheet you could just click file download as CSV okay if not you have any other they're sort of CSV just export it as you choose make sure it's saved as a CSV so now click Choose file right here it's going to bring up in this dialog box of course mine's in my downloads and should be right at the top here okay so I'm going to check this and untitled spreadsheet whatever and we're going to click import and this is going to import our notes if all is well if all is correct okay so let's click import so I'm sorry you can't really see this a little small but it says status and no imported items okay so the problem is somewhere in our importer and let's actually check it out let's go to the basic settings here and you'll notice somehow this import on submission got unchecked I might have done that one I was clicking around by accident and just did not notice it so import on submission needs to be checked here so sorry about that and let's go back to our feed and now let's as you can see it already has our file your file name will be right here so we don't have to upload it again you can just click import and this time you see that there was actually a progress bar going across since it created four nodes okay so let's check out our find content here and you can see the feed worked import incorrectly okay and let's go to edit and the body is also here it also looks like it didn't save my out there for some reason maybe I just was clicking around too fast or something okay so let's change this a little bit let's go back to our feed here and let's let's change some of these okay I have no idea okay and actually let's add a couple more this title needs to be unique okay and now I'm going it down let's says a CSV again okay so now I'm going to go back to our importer I'm going to do a choose file and I'm going to grab the new one this one right here we're going to open this they're going to import again okay so now you can see it says created two nodes and updated one node that's awesome so if we refresh our content here you can see our new items and the updated one which we change the title changed and if we go to the body you can see the bodies here as well okay so this imported node information off of a CSV and turned it into nodes if you wanted to delete all of the items we just created in your and most Drupal themes up top here there will be several rows of buttons I'll site import delete items log I have mine up here just because I usually do that in my projects for some reason I enjoy it I'm going to click delete items and click delete and just like that if we go to find content it deleted all of the feed items so let's say you import some data and it's not quite right and instead of just updating it you just want to get rid of it completely that's an easy way to make sure that the content that you've brought in with that feed it can just be deleted okay well that's how you import a CSV file using Drupal's feeds in the next lesson I'm going to show you how to use an RSS feed that's on the Internet to import into nodes once again this is Scott with level up tuts and thanks for watching
Info
Channel: LevelUpTuts
Views: 40,152
Rating: 4.8630137 out of 5
Keywords: tutorials, cms, html, css, html5, css3, education, free, lessons, tuts, tutorial, learn, software, web development, web developer, developer, web, website, Drupal, Tutorial, Data, Technology, Business, System, Management, Training, Systems, Information, Computer, Design, Using, xampp, drupal7, installing, level, up, Web Feed, Comma-Separated Values (File Format)
Id: YXgjFRn7ty4
Channel Id: undefined
Length: 11min 4sec (664 seconds)
Published: Wed Aug 01 2012
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.