[SciPy-User] Can loadtxt do this: complex file format

François Beaubert francois.beaubert@univ-valenciennes...
Mon Nov 26 07:18:00 CST 2012


Great David, it works for me !
I just have to change your previous converters dictionary with this one:

converters = {1: lambda s: float(s[1:]), 3: lambda s: float(s[:-1]),4: 
lambda s: float(s[1:]), 6: lambda s: float(s[:-1])}

Just have to find a way to automate this with the number of points I 
have in the header.

Many, many thanks David !
You've maid my day.

Cheers
François

Le lun. 26 nov. 2012 11:59:44 CET, Daπid a écrit :
> On Mon, Nov 26, 2012 at 10:16 AM, François Beaubert
> <francois.beaubert@univ-valenciennes.fr> wrote:
>
> converters = {2: lambda s: float(s[1:)), 4: lambda s: float(s[:-1)),
> 5: lambda s: float(s[1:)), 7: lambda s: float(s[:-1)))
> time,Ux1,Uy1,Uz1,Ux2,Uy2,Uz2 = loadtxt(filename, comments='#',
> skiprows = 4, delimiter=None, usecols=(0,1,2,3,4,5,6), unpack=True,
> converters = converters)
>
> I have added skiprows to jump over the first few lines, and the
> converters = converters to get rid off the " ( ". I insist, I haven't
> tested my converters function, so it may be wrong, but it should be
> easy to fix.
>
>
> David.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: francois_beaubert.vcf
Type: text/x-vcard
Size: 464 bytes
Desc: not available
Url : http://mail.scipy.org/pipermail/scipy-user/attachments/20121126/9660fb7c/attachment.vcf 


More information about the SciPy-User mailing list