Este é um exemplo do meu arquivo CSV:
04/Feb/2016:06:38:44-0500,ab,3,10,57,200,10254
04/Feb/2016:06:39:07-0500,cd,1,42,168,304,0
04/Feb/2016:06:39:07-0500,ef,1,43,169,304,0
04/Feb/2016:06:39:07-0500,ab,1,43,170,304,0
04/Feb/2016:06:39:07-0500,cd,1,44,171,304,0
04/Feb/2016:06:39:07-0500,ef,1,45,172,304,0
Eu gostaria de buscar a string na segunda coluna, criar um arquivo chamado assim, se o arquivo não existir e adicionar aquela linha específica em um arquivo. Então, algo assim:
fetch string in 2nd column -> "ab" -> if file doesnt exist create file called "ab.csv" -> open file and add line "04/Feb/2016:06:38:44-0500,ab,3,10,57,200,10254"
fetch string in 2nd column -> "cd" -> if file doesnt exist create file called "cd.csv" -> open file and add line "04/Feb/2016:06:39:07-0500,cd,1,42,168,304,0"
fetch string in 2nd column -> "ef" -> if file doesnt exist create file called "ef.csv" -> open file and add line "04/Feb/2016:06:39:07-0500,ef,1,43,169,304,0"
fetch string in 2nd column -> "ab" -> if file doesnt exist create file called "ab.csv" -> open file and add line "04/Feb/2016:06:39:07-0500,ab,1,43,170,304,0"
fetch string in 2nd column -> "cd" -> if file doesnt exist create file called "cd.csv" -> open file and add line "04/Feb/2016:06:39:07-0500,cd,1,44,171,304,0"
fetch string in 2nd column -> "ef" -> if file doesnt exist create file called "ef.csv" -> open file and add line "04/Feb/2016:06:39:07-0500,ef,1,45,172,304,0"
Resultado:
ab.csv:
04/Feb/2016:06:38:44-0500,ab,3,10,57,200,10254
04/Feb/2016:06:39:07-0500,ab,1,43,170,304,0
----------------------------------------------
cd.csv:
04/Feb/2016:06:39:07-0500,cd,1,42,168,304,0
04/Feb/2016:06:39:07-0500,cd,1,44,171,304,0
----------------------------------------------
ef.csv:
04/Feb/2016:06:39:07-0500,ef,1,43,169,304,0
04/Feb/2016:06:39:07-0500,ef,1,45,172,304,0
Qualquer ajuda appriciated!