Set trace=“true” in your template for more debugging help.
Could you post your CSVgrab template? Could you post some sample data and sample output? What happens if you put a different first row in the data file?
Double-check the custom field names to make sure there are no errors.
Did you upload the csv file from a Mac? If so, did you make sure to do it in text mode so the line endings are OK?
This plugin has proven to be helpful time and time again - thanks!
One question I have is whether there’s any way possible to import data from a custom field based on a weblog relationship. Might be a long shot, but if there’s a way or if someone has a suggestion I’d be happy to give it a shot.
Hi Kurt, if you don’t see a line that looks something like this:
TRACE: Resource id #49
in the TRACE output, then it is not even opening the file. What was the absolute file path you gave? It should be the actual filepath, such as you would use if you ssh’d into the server and wanted to access the file. If you can ssh in, make sure you can cat the file with that path.
Can you turn on PHP error reporting to see what’s going wrong with the file open or fetch? That info may also be in the server Apache error logs.
But it doesn’t seem to matter what path I use to get there (the URL or the sever path), its a no-go.
Ahh. . . from the sever log:
[Sat Oct 25 23:17:24 2008] [error] [client 00.000.000.000] PHP Warning: fgetcsv() [<a href=‘function.fgetcsv’>function.fgetcsv</a>]: enclosure must be a character in /var/www/vhosts/domain.org/httpdocs/system/plugins/pi.csvgrab.php on line 202
At last a clue. It doesn’t appear to like my enclosure’s character. . .
The encloser used to be optional, I think, in some previous version of PHP, but has now become required. However, the actual data is not required to have an encloser. If the encloser is present, then it will be used to quote the data so that you can have delimiter characters inside. So if you have
encloser="SPACE" delimiter="TAB"
then you are saying you may have data like this:
123<tab>456<tab><space>abc<tab>def<space><tab>xyz
That would break into fields like this. Notice that the third field has an embedded tab as part of the data:
"123" "456" "abc<tab>def" "xyz"
Since you are using tab-delimited data, it may be safer to use
encloser="QUOTE"
or some character you’re not expecting at all, just in case one of your fields starts with a space. If it did, that field eat up the rest of the characters, including the following tabs, until there awas another space.
I downloaded your test.csv file and looked at it. It contains only carriage returns (\r), no linefeeds (\n). So it is a Mac text file, with Mac line endings, which PHP does not handle. You have to upload it in text mode so that the line endings will be converted to something that PHP understands. Or edit it locally and convert the “\r"s to “\r\n” or “\n”. That is your main problem.
A note: encloser=“SPACE” is really weird. That means that spaces are acting as quotes. encloser=“QUOTE” is fine and the quotes are then optional.
Thanks for the reply. I changed it to a txt file and set delimeter=“TAB” but I am still not getting the data into the weblog. Is there something else I am missing?
I changed back to test.csv, added a return to the last line and uploaded (yes you were correct) using Transmit. I changed the mode to ASCII (Text). I also changed the file in go to test.csv. My other settings are:
You have use=“3|4|5|6|7|8” (six fields), but only five fields are in fields=“golf_addr|golf_city|golf_state|golf_zip|golf_phone”. I think you don’t mean to have the “|8”. If these don’t match up, CSVgrab fails silently.
Set trace=“true” which will give you more debugging output. That will help if there are further problems.
Also your latest CSV file seems to have too many columns in it, though I don’t think that should cause a problem.