Search code examples
pythongoogle-app-enginebulkloader

appengine import_transform two function at the same time: truncate & export_date_time


I have this datetime 2011-07-02 03:03:32.793

To deal with the millisecond issue with python 2.5 version(mentioned here), I try to truncate it & convert it date time as:

import_transform: 'lambda x: x[:18]'
import_transform: transform.import_date_time('%Y-%m-%d %H:%M:%S')

How can I write these two import_transform in one line?


Solution

  • You can do this by writing a lambda function that does both together:

    import-transform: lambda x: transform.import_date_time('%Y-%m-%d %H:%M:%S')(x[:18])
    

    Note the chained function calls - transform.import_date_time returns a function, which you're then calling.