[Tutor] genfromtxt and dtype to convert data to correct format

Alan Gauld alan.gauld at yahoo.co.uk
Wed May 18 18:19:57 EDT 2016


On 18/05/16 14:14, Ek Esawi wrote:
> OPS! Sorry, I made a mistake on the posting. My output is in a string
> format as shown below. I want the 1st and 8th integers, the 3rd string
> which is OK as, the 2nd date and the rest time. 

You will need to convert the integers manually I suspect
with int(row[0]) and int(row[7]).

For the dates and times, what happens if you simply remove
the strftime() functions from your lambdas?

Things are complicated slightly by your use of genfromtxt since
it's part of numpy and not in the standard library. I have
no idea what it does so there may be tricks you can do with
it.

> [ (b'312171', '1995-07-01', b'Old', '13:37:00', '01:43:00', '04:42:00',
> '13:16:00', b'162', '13:19:00')


-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list