[Tutor] csv manipulation
A.T.Hofkamp
a.t.hofkamp at tue.nl
Wed Oct 29 16:08:36 CET 2008
qsqgeekyogdty at tiscali.co.uk wrote:
> hello,
> i have the follwoing csv file:
>
> "Berat","Berat","Kuçovë","Skrapar"
> "Dibër","Bulqizë","Dibër","Mat"
> "Durrës","Durrës","Krujë"
> "Elbasan","Elbasan","Gramsh","Librazhd","Peqin"
> "Fier","Fier","Lushnjë","Mallakastër"
> "Gjirokastër","Gjirokastër","Përmet","Tepelenë"
> "Korçë","Devoll","Kolonjë","Korçë","Pogradec"
> "Kukës","Has","Kukës","Tropojë"
> "Lezhë","Kurbin","Lezhë","Mirditë"
> "Shkodër","Malësi e Madhe","Pukë","Shkodër"
> "Tirana","Kavajë","Tirana"
> "Vlorë","Delvinë","Sarandë","Vlorë"
>
> where thee first column contains the regions and the subsequent the
> districts.
>
> what is the best way to return a file like:
>
> "Berat","Kuçovë"
> "Berat","Skrapar"
> "Dibër","Bulqizë"
> "Dibër","Dibër"
> "Dibër","Mat"
>
> etc...
>
> and to write it out as a new file.
Python has a 'csv' library, which handles your kind of files.
I have never used it however, so I cannot give you more details.
Good luck,
Albert
More information about the Tutor
mailing list