Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > Linux Forums > Programming/Scripts

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 24th April 2007, 15:59
pnsreee pnsreee is offline
Junior Member
 
Join Date: Apr 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Thumbs up Getting columns from csv file in perl

Hi All,

How can i get columns from cvs file into an array with out using Text::xSV or Text::CSV_XS.
The CSV file is a dynamic file.

the fields are like this

Numb,Name,Class,Type,......

201,Bazaar,b2,53,..........

121,Raymond,y1,02,...

232,Robert,p1,04,...............




I am using following code to get columns.

@tmp = `more +2 flat1.txt | cut -d "," -f $i` ;

It is giving out put and also error saying that refer help.
Can any one give me equivalent to this
Reply With Quote
Sponsored Links
  #2  
Old 24th April 2007, 16:48
ghostdog74 ghostdog74 is offline
Junior Member
 
Join Date: Aug 2006
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
 
Default

you are using perl, and then you are using other OS tools like more and cut. this is overkill. in perl , you can split your string eg perldoc -f split, you can see how its done. if you want to use shell tools, awk can do that.

Last edited by ghostdog74; 24th April 2007 at 16:52.
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Chroot SSH + ISPConfig Norman Installation/Configuration 27 26th March 2007 03:40
Dspam planet_fox General 6 20th January 2007 18:42
Systemimager (rsync) doesn't copy all comedit HOWTO-Related Questions 11 19th January 2007 17:17
HotSaNIC domino Tips/Tricks/Mods 23 6th November 2006 05:19
jamed up my table borders?? Boon-Dog-Danny Installation/Configuration 5 23rd September 2006 16:12


All times are GMT +2. The time now is 22:42.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.