Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > fr.comp.lang.python > #3738
| 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 | 2022-02-03 19:45 +0100 |
| Organization | Université de Strasbourg |
| Message-ID | <871r0jpz4o.fsf@universite-de-strasbourg.fr.invalid> (permalink) |
| References | <l96dnV9hCoG-A2_8nZ2dnUU7_83NnZ2d@giganews.com> <61f3037b$0$8902$426a34cc@news.free.fr> <NaCdnRoVa4EBdWb8nZ2dnUU7_83NnZ2d@giganews.com> |
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.00070
> 0.00002 0.00001 0 0.00001 0 0 0.00010 0.00008 0.00002 0.00012 0.00015 0.00001
> 0.00022 0.00028 0.00005 0 0.00002 0 0 0 0 ; 0.00010 0.00004 0.00006 0.00010
> 0.00020 0.00002 0.00001 0 0.00004 0.00002 0 0.00018 0.00010 0.00002 0.00008
> 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), ça s'apparente à de l'autoflagellation. Essaie :
with open (.....) as f:
m = [[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 = [[]]
for line in f:
for f in line.split ():
if f == ";":
m.append ([])
else:
m[-1].append (float (f))
(pas testé).
-- Alain.
Back to fr.comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar
Projet Python : importation d'un dossier csv sous forme de matrice Mand1n3 <nospam_playfairalikecestatut@outlook.com.invalid> - 2022-01-27 07:29 -0600
Re: Projet Python : importation d'un dossier csv sous forme de matrice yves <yves@free.invalid> - 2022-01-27 20:41 +0000
Re: Projet Python : importation d'un dossier csv sous forme de matrice mand1n3 <nospam_playfairalikecestatut@outlook.com.invalid> - 2022-02-03 08:37 -0600
Re: Projet Python : importation d'un dossier csv sous forme de matrice Alain Ketterlin <alain@universite-de-strasbourg.fr.invalid> - 2022-02-03 19:45 +0100
Re: Projet Python : importation d'un dossier csv sous forme de matrice yves <yves@free.fr.invalid> - 2022-02-04 18:23 +0100
Re: Projet Python : importation d'un dossier csv sous forme de matrice yves <yves@free.fr.invalid> - 2022-02-04 19:11 +0100
Re: Projet Python : importation d'un dossier csv sous forme de matrice Olivier Miakinen <om+news@miakinen.net> - 2022-01-27 22:11 +0100
Re: Projet Python : importation d'un dossier csv sous forme de matrice K. <secwin88@yahoo.co.jp> - 2022-01-27 21:30 +0000
Re: Projet Python : importation d'un dossier csv sous forme de matrice K. <secwin88@yahoo.co.jp> - 2022-01-27 21:41 +0000
csiph-web