The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Special Forums > UNIX and Linux Applications
.
google unix.com



UNIX and Linux Applications Discuss UNIX and Linux software applications. This includes SQL, Databases, Middleware, MOM, SOA, EDA, CEP, BI, BPM and similar topics.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
utilities subhendu81 UNIX for Advanced & Expert Users 5 03-09-2009 06:26 AM
how to run utilities hershey101 UNIX for Dummies Questions & Answers 1 06-20-2008 01:27 AM
bc and wc utilities??? skyineyes UNIX for Dummies Questions & Answers 6 05-29-2008 12:46 PM
Awk Utilities jyo123.jyothi Shell Programming and Scripting 10 05-08-2008 05:45 AM
Awk Utilities jyo123.jyothi Oracle Updates (RSS) 0 05-08-2008 04:19 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-16-2009
Corona688 Corona688 is offline
Registered User
  
 

Join Date: Aug 2005
Location: Saskatchewan
Posts: 1,928
Utilities for CSV

I'd like to be able to do something like 'select column_a column_c column_b from file.csv'. Scripting it probably wouldn't be too extraordinarily difficult but I'd rather not reinvent the wheel if someone's built a better one already.
  #2 (permalink)  
Old 04-16-2009
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,119
A full-blown SQL or just a simple 'select' (with configurable column names/numbers)?
  #3 (permalink)  
Old 04-17-2009
Corona688 Corona688 is offline
Registered User
  
 

Join Date: Aug 2005
Location: Saskatchewan
Posts: 1,928
Just a simple select to pick and rearrange columns.
  #4 (permalink)  
Old 04-17-2009
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,119
something along these lines (but I bet you meant something more elaborate):

nawk -v select='1,5,3' -f csv.awk csv.csv

csv.awk:
Code:
BEGIN {
   FS=OFS=","
   selN=split(select, selA, FS)
}
{
  for(i=1; i<=selN; i++)
     printf("%s%c", $selA[i], (i==selN)?ORS:OFS)
}
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 03:13 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0