LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 10-24-2006, 08:28 AM   #1
richmur
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, 08:34 AM   #2
jim mcnamara
Member
 
Registered: May 2002
Posts: 964

Rep: Reputation: 34
Code:
awk -F, '{ print $2 > $1 }' myfile.csv
Assuming I understood what you wanted....
 
Old 10-24-2006, 08:39 AM   #3
richmur
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.
 
  


Reply


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 (filename.so) afx2029 Linux - Software 4 08-17-2007 06:07 AM
Basic Perl - removing white from split field. ryedunn Programming 7 09-13-2006 12:24 AM
How to split file , .. awk or split ERBRMN Linux - General 9 08-15-2006 12:02 AM
change uploaded files from filename.avi to filename.avi.html like www.rapidshare.de latheesan Linux - Newbie 3 06-16-2005 04:33 AM
filename- and filename~ files? slinky2004 Linux - Newbie 5 10-17-2004 10:32 PM


All times are GMT -5. The time now is 10:18 PM.

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