I do not think the CSV formatting belongs in the model. There may be
difference places in an app where importing is done suing different
conventions. And why for csv and not xml? etc.

I will just post an example of how to create your own importer. It is
very short and easy.

Massimo

On Mar 31, 1:31 pm, DenesL <denes1...@yahoo.ca> wrote:
> We could have a field.csv_in (similar to field.requires) that runs
> when table.import_from_csv_file is called and passes it the current
> value (this could go inside the current 'fix' function).
>
> So you can do, e.g.
>
> table.field.csv_in=IS_DATETIME('%d/%m/%Y %H:%M',error_message='must be
> D/MM/YYYY HH:MM'))
>
> before the import.
> The errors could be written out to a csvfilename+'_error' file.
>
> Obviously field.csv_in would not be limited to validators and could do
> other things, it just has to behave like them returning a
> value,message pair and if message!=None (as with validators) it would
> mean that the current value is in error.
>
> On Mar 31, 11:31 am, mdipierro <mdipie...@cs.depaul.edu> wrote:
>
> > On Mar 31, 10:48 am, Fran <francisb...@googlemail.com> wrote:
>
> > > On Mar 31, 5:13 pm, Yarko Tymciurak <yark...@gmail.com> wrote:
>
> > > > Before you export from excel, you should be able to set your date field
> > > > format to something that will work, for example, in  format cells -> 
> > > > number
> > > > -> Custom
> > > > set the field to yyyy-mm-dd hh:mm:ss
>
> > > > That matches what you are saying the field "should be", and excel should
> > > > then export in this format to csv.
>
> > > Thanks a lot, that works.
> > > I'd previously tried setting to 'generasl' hoping it would lave well-
> > > alone.
> > > Perhaps 'text' was what I meant.
>
> > > Anyway, no way we can get Web2Py to allow either format for entry?
>
> > The point is:
>
> > 1) should web2py enforce a csv convention
> > 2) should web2py be customizable to read any CSV
>
> > So far we followed the approach 1) since it is easier to convert a CSV
> > using excel that write the code for your own customization.
> > Moreover 2) is never going to satisfy everybody and the csv module is
> > very flexible anyway. You can use IS_DATE(format)(value)[0] to convert
> > to ISO yourself from any format.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to