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 <[email protected]> wrote:
> On Mar 31, 10:48 am, Fran <[email protected]> wrote:
>
>
>
> > On Mar 31, 5:13 pm, Yarko Tymciurak <[email protected]> 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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to