|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
[Solved] Perl Question - split function with csv file
Hi all, I have a csv file that appears as follows: Code:
,2013/03/26,2012/12/26,4,1,"2017/09/26,5.75%","2017/09/26,1,2018/09/26,1,2019/09/26,1,2020/09/26,1,2021/09/26,1",,,2012/12/26, now when i use the split function like this: Code:
my @f = split/,/; the split function will split the data that is within the ". What I need to do is still split based on a "," but not look at the "," that are in the quotes. I'm pretty stumped here. Any help would be greatly appreciated. Last edited by radoulov; 01-23-2013 at 01:41 PM.. Reason: Marked as solved. |
| Sponsored Links | ||
|
|
#2
|
||||
|
||||
|
Code:
#! /usr/bin/perl
use Text::ParseWords "quotewords";
open F, "< file";
while (<F>) {
chomp;
@new = quotewords(",", 0, $_);
for (@new) { print "$_ || " }
print "\n";
}
close F;Code:
$ ./test.pl || 2013/03/26 || 2012/12/26 || 4 || 1 || 2017/09/26,5.75% || 2017/09/26,1,2018/09/26,1,2019/09/26,1,2020/09/26,1,2021/09/26,1 || || || 2012/12/26 || || |
| The Following User Says Thank You to balajesuri For This Useful Post: | ||
PikK45 (01-23-2013) | ||
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
works!!! thanks!!!
|
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Perl split function | vishwakar | Shell Programming and Scripting | 3 | 09-16-2011 10:47 AM |
| split xlsx to csv using perl | malikshahid85 | Programming | 1 | 08-18-2010 04:10 AM |
| PERL split function | castle | Shell Programming and Scripting | 1 | 02-21-2010 05:28 AM |
| Use split function in perl | chriss_58 | Shell Programming and Scripting | 5 | 06-13-2008 05:50 AM |
| perl split function | new2ss | Shell Programming and Scripting | 5 | 06-08-2006 10:17 PM |
|
|