The parameter skip stands for the number of lines in your document you want to skip. The delimiter parameter stands for the separation of values on a single line. like SPACE TAP or , or ; The encloser is about the enclosure of values. Example: “value” or ‘value’ Use works together with the fields parameter. With use you point to the column in de csv file. And with fields you select a custom weblog field.
i hoop this will help
Thanks, Maix. I appreciate you response.
I get that “use” works together with the fields parameter, but as I asked before, does that mean the fields you’re pulling or the fields you’re importing into? For the delimiter, I don’t know why I would choose TAB or COMMA or SPACE TAP, etc. over another. Which one is most common place? Why one over the other? And why would I want to “skip” such n’ such amount of lines? How do I know if I want single or double quotes for my enclosure values?
See what I mean? 😊 I mostly handle front-end stuff, but would love to learn more about database whatnot so I don’t have to ask so many questions. I think a practical, everyday example in the docs would be really helpful to those who aren’t well-versed in database tables and columns. (i.e., your Average Joe who wants to just move basic blog entries from one EE blog to another. Nothing fancy, just your garden variety type thing.)
Thanks again for your help, Maix! Any additional input would be greatly appreciated.
Thanks!
Joelle,
I’ll do my best to answer your questions.
I get that “use” works together with the fields parameter, but as I asked before, does that mean the fields you’re pulling or the fields you’re importing into?
The “use” and “fields” work together, as you’ve stated, and it tells the plug-in what data to enter where. The “use” digits refer to existing columns in your database, from the CSV file. The “fields” are what you’ve set up in EE as weblog custom fields. For example, if you have a field called “article-summary” and the CSV data to match is in column “6”, you would enter use=”6” and fields=”article-summary”. More than one field to fill up with data? Just use the pipe character, “|”, as instructed.
For the delimiter, I don’t know why I would choose TAB or COMMA or SPACE TAP, etc. over another. Which one is most common place? Why one over the other?
In my experience, it doesn’t matter, just how your CSV file is set up, though I usually pick comma. If you’re exporting from Microsoft Excel, you can choose all sorts of different delimiters. Same with phpMyAdmin or other web database managers. The delimiter simply structures the database into unique columns that the plug-in can interpret.
How do I know if I want single or double quotes for my enclosure values?
Again, it’s how your CSV file is configured. I don’t think it really matters, as I’ve used both without a hitch.
Oh, one more quick question: the skipping of lines. How do I know I want to skip lines and how does one determine that? If, let’s say, I was using the default weblog fields and I’ve exported the .csv file from phpMyAdmin. I want to import those entries into a new weblog using similar fields. You’ve shared how to tell what columns to populate which fields, but do I need to worry about skipping lines?
Thanks again!
In that case you have nothing to skip.
In some other cases the first line of the csv file is used for the name/description of the data columns then you want to skip them. Or when you have a product list were the first 100 lines/items are already in ExpressionEngine. You can skip them with skip=”100”
So then do I need the “use” information? I’m not sure what “2|3” even are. lol.
I just exported the entire database from the old site and now I want to pull entries from “X” EE weblog in the old database (.csv file) into “Y” EE weblog on a new installation of EE. Would I put something like this?
{exp:csvgrab url="http://domain.com/myfile.csv"
weblog="5"
title="1"
delimiter=";"
encloser="QUOTE"
use="2|3"
fields="body|extended"}
The weblog I want to import into is 5 and according to phpMyAdmin the delimiter is a semicolon (“Fields terminated by ;”). It also says that “Fields enclosed by quote”. Like I said, I’m not sure what use=”2|3” is exactly. How do I know what columns I want to use? Where does that information live?
Does this look right? I tried using this and it just pulled in a bunch of jumbled rubbish entries and spit out php errors.
Thanks again! 😊
Joelle,
2|3 are the columns in your CSV database. For example, this is a snippet from my CSV file representing 3 columns separated by a comma:
"Dawson City residents choose their world's Seven Wonders","2007-10-22","4",
If I wanted to import the title “Dawson City residents choose their world’s Seven Wonders” and category “4” into EE, I would use 1|3.
As for your errors, use a debugging method. To do this, create a simplified duplicate of your CSV with only a few entries (2 or 3 at most) and then import that with the CSVGrab plug-in. Start with a single use/field and if it works, add another. Keep doing this until you produce an error, then let us know what the error message is.
Just to clarify, the category_field parameter selects which column of the CSV file to use for categories.
There is another parameter called category which selects a default EE category to put the entry in.
Unfortunately, neither allow you to use the “9|14|87” format that you asked about, but I can see how it would be useful (in the category=”9|14|87” case at least).
I’m currently working on an updated version of this plugin, but email or PM me if you need this functionality urgently.
Hi,
I am having problems with importing a date field with csvGrab (version 0.11). The template I am using is:
{exp:csvgrab url="http://localhost/EE/new10-a.csv"
weblog="1"
title="1"
skip="2"
delimiter="TAB"
encloser="QUOTE"
use="2|3|5"
fields="summary|body|date" }
and this imports the data fine except for the date field all of which are set to January 1 1970.
The date field in my csv is formatted like “1998-10-22”
The error that is generated is
Notice: Undefined index: in /var/www/EE/system/plugins/pi.csvgrab.php on line 186
Any ideas on how to get csvGrab to grab the correct date?
SOLUTION:
Add date”5” to code above ie:
{exp:csvgrab url="http://localhost/EE/new10-a.csv"
weblog="1"
title="1"
skip="2"
delimiter="TAB"
encloser="QUOTE"
date="5"
use="2|3"
fields="summary|body" }
I’ve a new(-er) version of CSVGrab that you can try. Its much the same on the surface, but is cleaned up a bit underneath. It handles dates a little better than previously.
To get dates working, add a date parameter to indicate which column to use for the date, eg, date=”5”. It currently only looks for dates in YYYY-MM-DD format.
Edit: Please see the CSVGrab page to download current version
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.