I'm trying to import some data into a flexinode content type that has some date fields and I can't figure out what the "date" data in the file should look like. If I use these date formats they all get converted wrong:

Spreadsheet Shown in preview of import
Sat, 2005-12-31 09:00 Wed, 1969-12-31 17:00
19990130 Thu, 1970-08-20 01:48
02/30/1999 Wed, 1969-12-31 17:00
03301999 Wed, 1969-12-31 17:00
04-30-1999 Wed, 1969-12-31 17:00

Any ideas what format I should use to map into a date field?

Thanks,

Vicki

Comments

Robrecht Jacques’s picture

You need a file like:

title,name,type,ctype_id,flexinode_3,flexinode_2month,flexinode_2day,flexinode_2year,flexinode_2hour,flexinode_2minute
"Foo",bar,flexinode-2,2,"something",4,26,2001,18,0
...

Things might get easier when the CVS-HEAD version gets released.

vprugh’s picture

I think I did bring down the CVS Head version, but when I go to the mapping part, it doesn't show the individual components of the dates, and when I map each one to the field:

flexinode_30day=term_date
flexinode_30month=term_date
flexinode_30year=term_date

It still comes out wrong.

This is the version I'm using:
// $Id: node_import.module,v 1.15 2005/06/20 21:21:31 drumm Exp $

Any thoughts?

Robrecht Jacques’s picture

node_import.module is being rewritten in CVS. We're still working on a simpler way to import date fields (either in flexinode or event). I hope to have enough time this evening to submit a patch.

In the meantime, if you are using the CVS version (v1.15 for example), you will need to use the "raw data (advanced)" option. So, don't select the content type in the first page from the select dropdown. With the "raw data (advanced)" option you can import any content node, but your fieldnames (=column names) need to be correct (no field matching). So you need a seperate column for flexinode_30day, ..._30month, ..._30year, ..._30hour AND ..._30minute (you will need every column!). And you need a "type" (flexinode-XX), "name" and "ctype_id" (XX) column too.

Hope this helps.

vprugh’s picture

Awesome!... that did it! Thanks! Is there any way I can assign it to a category which it would have prompted for had I chosen a flexinode type?

Robrecht Jacques’s picture

No, not at the moment. This is being worked on.

There is no way to assign "taxonomy terms" (or categories like you call them) when using "raw data (advanced)". And there is no way (currently) to assign a date if you don't use "raw data (advanced)". So it is either "assign a date" or either "assign a category" for the moment.

Things will improve in the following hours -- at least that is the plan for me this evening :-)

vprugh’s picture

Thanks Jacques,

I really appreciate all your help (now AND in tonight ;-) I really like this module. It's SUCH a timesaver! Could I ask you one more thing? If it's something you don't know off the top of your head, don't worry about it. I'm importing some data in the CSV that I'd like to have carriage returns imbedded in (for things like an address), so I've inserted
where I need them. However the default input format is "filtered html" which seems to expect you to type the actual carriage returns in the text area. Is there something I can put in the data that simulates a carriage return in the "filtered html"?

Thanks again for everything!

Vicki

vprugh’s picture

I found it... I just needed to configure the input format to allow
... sorry for the sidetrack :-)

Robrecht Jacques’s picture

Some ways I can think of right now:

  1. The "filtered HTML" should already do the "right" thing. In your CSV file you need something like:
    title,body,...
    "foo","My address is:
    foo
    bar
    (an empty line here)
    This will be a new paragraph.
    This will be a second line of the second paragraph.
    (an empty line here)
    This is a third paragraph.",...
    

    Paragraphs are seperated by at least one empty line (which seems to be filtered out here, so I've put "(an empty line here)" instead). If you insert a linebreak (like between "foo" and "bar"), you'll get a <br>

  2. Add <br> as an allowed HTML tag to the "filtered HTML". This is done on the "administer (menu) => input formats (menu) => configure (next to "filtered html" radio option) => configure (tab)" and add <br> to the list of "Allowed HTML tags", you can then use <br> where you want a linebreak. You now allow all users to use <br> in their comments etc. This is no real problem;
  3. Change the default format (on the "administer => input formats" page) to "Full HTML". You can now use <br> where you want a linebreak. Don't forget to change it back because this is quite insecure if you let anonomous users (or even members) add comments (or other content) because now they will be able to insert ANY HTML in their comments;
  4. Probably you can specify which "input format" to use in the CSV file itself. Something with a column named "flexinode_XX_format" (where XX is the number of the textarea field of your flexinode type) which you set to "3" (Full HTML - at least in my default installation) for each row.

There are probably other methods too :-)

Robrecht Jacques’s picture

Status: Active » Closed (fixed)

Closing this support issue:
- original poster was helped and solved her problem.
- the things I promised to do is: http://drupal.org/node/24910 . This has only partly been committed.

ontoligent’s picture

More: It looks like the node_import_valid_date function is broken, since it is looking for a number. Here's what I did to fix it temporarily -- if this is valid. someone should make it into a patch.

function node_import_valid_date($date) {
	if (preg_match("/^\s*\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\d\s*$/", $date)) {
		return $date;
	} else {
		return -1;
	}
	/*
  //TODO: really check whether the date is valid!!

  if (empty($date)) {
    return -1;
  }
  if (is_numeric($date) && $date > -1) {
    return $date;
  }
  $time = strtotime($date);
  if ($time < 0 || !$time) {
    return -1;
  }
  return $time;
	*/
}