-   Programming (
-   -   Split CSV, field as filename (

richmur 10-24-2006 08:28 AM

Split CSV, field as filename
I have a csv file with 2 columns, first contains a code e.g. X467 the second contains some text. Any ideas how to create a bunch of txt files with the first field as the filename and the second field as the contents of the txt file - thanks

sample csv:

X467, This is the sample text
Z5439, This is some more sample text
Y56, Final line

jim mcnamara 10-24-2006 08:34 AM


awk -F, '{ print $2 > $1 }' myfile.csv
Assuming I understood what you wanted....

richmur 10-24-2006 08:39 AM

Perfect - much appreciated! That worked a charm, I had been trying to do it using perl, grep and anything else I could think of.

All times are GMT -5. The time now is 11:20 AM.