views:

117

answers:

1

i use remote_api to load data from google-app-engine.

appcfg.py download_data --config_file=helloworld/GreetingLoad.py --filename=a.csv  --kind=Greeting helloworld

the setting is:

class AlbumExporter(bulkloader.Exporter):
    def __init__(self):
        bulkloader.Exporter.__init__(self, 'Greeting',
                                     [('author', str, None),
                                      ('content', str, None),
                                      ('date', str, None),
                                     ])

exporters = [AlbumExporter]

and i download a.csv is :

alt text

the date is not readable ,

and the date in appspot.com admin is :

alt text

so how to get the full date ??

thanks

i change this :

class AlbumExporter(bulkloader.Exporter):
    def __init__(self):
        bulkloader.Exporter.__init__(self, 'Greeting',
                                     [('author', str, None),
                                      ('content', str, None),
                                      ('date', lambda x: datetime.datetime.strptime(x, '%m/%d/%Y').date(), None),
                                     ])

exporters = [AlbumExporter]

but the error is :

alt text

updated

it is ok now , thanks

('date', lambda x: datetime.datetime.strftime(x, '%m/%d/%Y'), None),
+1  A: 

Looks like you're getting a truncation at the space in the third column when you say

('date', str, None),

(the other attempt is clearly wrong because you're getting a datetime and you can't strptime that!-). If you want the date as a string, try:

('date', lambda dt: str(dt.date()), None),

or, change strptime to strftime in your second attempt. Mnemonic: the f in strftime stands for *f*ormat: take a datetime and format it to a string; the p in strptime stands for *p*arse: take a string and make a datetime out of it. They're old names, coming from the standard library for ANSI C (and even-earlier influences on it)...

Alex Martelli