Deutsch English Français Italiano |
<871r0jpz4o.fsf@universite-de-strasbourg.fr.invalid> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!news.mixmin.net!aioe.org!8V/RyHTQh/qvHt+9oBZ6lA.user.46.165.242.75.POSTED!not-for-mail From: Alain Ketterlin <alain@universite-de-strasbourg.fr.invalid> Newsgroups: fr.comp.lang.python Subject: Re: Projet Python : importation d'un dossier csv sous forme de matrice Date: Thu, 03 Feb 2022 19:45:59 +0100 Organization: =?utf-8?Q?Universit=C3=A9?= de Strasbourg Message-ID: <871r0jpz4o.fsf@universite-de-strasbourg.fr.invalid> References: <l96dnV9hCoG-A2_8nZ2dnUU7_83NnZ2d@giganews.com> <61f3037b$0$8902$426a34cc@news.free.fr> <NaCdnRoVa4EBdWb8nZ2dnUU7_83NnZ2d@giganews.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: gioia.aioe.org; logging-data="62311"; posting-host="8V/RyHTQh/qvHt+9oBZ6lA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org"; User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) Cancel-Lock: sha1:t6zo4ktvpg/6Lj0gf0sNGhvDV3c= X-Notice: Filtered by postfilter v. 0.9.2 Bytes: 2266 Lines: 35 mand1n3 <nospam_playfairalikecestatut@outlook.com.invalid> writes: > 0.00055 0.00008 0.00035 0.00038 0.00048 0.00011 0.00005 0.00009 0.00031 0= ..00006 > 0 0.00014 0.00020 0.00006 0.00009 0.00048 0.00022 0.00007 0.00018 0.00026 > 0.00004 0.00009 0 0.00001 0.00003 0 ; 0.00085 0.00004 0.00007 0.00004 0.0= 0070 > 0.00002 0.00001 0 0.00001 0 0 0.00010 0.00008 0.00002 0.00012 0.00015 0.0= 0001 > 0.00022 0.00028 0.00005 0 0.00002 0 0 0 0 ; 0.00010 0.00004 0.00006 0.000= 10 > 0.00020 0.00002 0.00001 0 0.00004 0.00002 0 0.00018 0.00010 0.00002 0.000= 08 > 0.00011 0.00004 0.00003 0.00005 0.00003 0.00004 0.00020 0 0 0 0 C'est du csv inhabituel, et pour stocker une matrice 26x26 (et pas 25x25), =C3=A7a s'apparente =C3=A0 de l'autoflagellation. Essaie : with open (.....) as f: m =3D [[float (w) for w in b.split()] for b in f.read().split(";")] si le fichier n'est pas trop grand, et sinon with open (.....) as f: m =3D [[]] for line in f: for f in line.split (): if f =3D=3D ";": m.append ([]) else: m[-1].append (float (f)) (pas test=C3=A9). -- Alain.