in reply to AWK? Split one file in seperate files based on country
A one liner:
perl -F; -anle"$F[0] ne $last and open F, '>', $F[0].'.csv'; print F; +$last = $F[0]" junk.dat C:\test>dir *.csv 30/05/2012 23:17 204 Albani‰.csv 30/05/2012 23:17 194 Andorra.csv 30/05/2012 23:17 325 Belgi‰.csv 30/05/2012 23:17 394 Engeland.csv 30/05/2012 23:17 295 Finland.csv 30/05/2012 23:17 332 Frankrijk.csv C:\test>type Albani‰.csv Albanië;Albanië;Berat;Hotel;Berati;40,9999;19,99999;Meer;ok;0; Albanië;Albanië;Berat;Hotel;Castle Park;45,769969;19,9999;Meer;ok;0; Albanië;Albanië;Berat;Hotel;Mangalemi;40,709999;19,959999;Meer;ok;0; C:\test>type Andorra.csv Andorra;Andorra;El Serrat;Hotel;Subi;43,658607;5,568623;;ok;0; Andorra;Andorra;El Serrat;Hotel;Tristan;42,618507;1,538923;;ok;0; Andorra;Andorra;El Tarter;Hotel;Del;42,580340;1,648919;;ok;0; C:\test>type Belgi‰.csv België;Antwerpen;Antwerpen;Bezienswaardigheid;Boerentoren (Kbc Toren); +51,2000;4,399000;;ok;0; België;Antwerpen;Antwerpen;Bed&Breakfast;Borze;51,2200;4,399000;;ok;0; België;Antwerpen;Antwerpen;Bed&Breakfast;Boulevard ;51,220000;4,399000 +;;ok;0; België;Antwerpen;Antwerpen;Appartement;Britselei 37;51,220000;4,399000 +;;ok;0;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: AWK? Split one file in seperate files based on country
by jwkrahn (Abbot) on May 31, 2012 at 01:58 UTC | |
by BrowserUk (Patriarch) on May 31, 2012 at 09:46 UTC | |
by jwkrahn (Abbot) on May 31, 2012 at 10:53 UTC |