Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 10-24-2006, 09:28 AM   #1
LQ Newbie
Registered: Aug 2005
Distribution: Suse 10.0
Posts: 7

Rep: Reputation: 0
Question 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
Old 10-24-2006, 09:34 AM   #2
jim mcnamara
Registered: May 2002
Posts: 964

Rep: Reputation: 36
awk -F, '{ print $2 > $1 }' myfile.csv
Assuming I understood what you wanted....
Old 10-24-2006, 09:39 AM   #3
LQ Newbie
Registered: Aug 2005
Distribution: Suse 10.0
Posts: 7

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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert static library (Filename.a) to dynamic shared object ( afx2029 Linux - Software 4 08-17-2007 07:07 AM
Basic Perl - removing white from split field. ryedunn Programming 7 09-13-2006 01:24 AM
How to split file , .. awk or split ERBRMN Linux - General 9 08-15-2006 01:02 AM
change uploaded files from filename.avi to filename.avi.html like latheesan Linux - Newbie 3 06-16-2005 05:33 AM
filename- and filename~ files? slinky2004 Linux - Newbie 5 10-17-2004 11:32 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:19 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration