I am making a script that extract informations in a cvs file. Each columns is separated by ";". The output should be a list of strings containing the column i want to extract.
I want to do this with comprehensive list, I would like to do something like :
[ c[1] for c as l.split(";") in for l in lines ]
And if you know Python you'll guess that it doesn't work. How could I achieve something like that ?
Of course I could use [ l.split(";") for l in lines ]
but in fact I need to extract several columns so doing multiple split isn't the right choice.
File looks like :
115239747;darwin;simone;simone@gmail.com;678954312
112658043;de beauvoir;charles;charles@laposte.net;745832259
115831259;ramanujan;godfrey;godfrey@etu.univ.fr;666443810
114873956;hardy;srinivasa;srini@hotmail.com;659332891
114823401;germain;marguerite;marg@etu.univ.fr;768532870
115821145;yourcenar;sophie;sophie@gmail.com;645388521
114560013;harendt;michel;micha@etu.univ.fr;666458200
115702831;foucault;hannah;ha@laposte.net;691337456
And i'd like to extract second and third columns.
Edit: I wan't to only use Python language features (no cvs library) because it is for a beginner course about Python. Thank you.