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. The date is not readable.
How to get the full date?
I changed 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]
However, I am still getting an error.
Looks like you’re getting a truncation at the space in the third column when you say
(the other attempt is clearly wrong because you’re getting a
datetimeand you can’tstrptimethat!-). If you want the date as a string, try:or, change
strptimetostrftimein your second attempt. Mnemonic: thefinstrftimestands for format: take a datetime and format it to a string; thepinstrptimestands for parse: 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)…