| |||||||||||
| |||||||||||
Adding comma(,) after every number+ perl Posted by ksamir2004 (ksamir2004), 15 May 2008 Hello All,i am new member of this forum. can any one help me for adding comma(,). after every number. i have excel file. in that file there is more then 100 number in single row seperated by column . i want perl script which read form excel and add comma (,). example : 11226 11342219 11990841 12001109 12006533 Solution: 11226,11342219,11990841,12001109,12006533 --------------------------------------------- open MARGIN, “<x.csv” or die “open x.csv: $!”; while (<MARGIN>) { chop; (@content) = split /,/; $prod_margin{$content[1]} = @content; } close MARGIN; open MARGIN, “>myout.csv” or die “open .csv: $!”;\ for my $line (keys %prod_margin) { print MARGIN $line, "\n"; } close MARGIN -------------------------------------------- plz help us. Thanks Sam Posted by admin (Graham Ellis), 16 May 2008 Sample solution and codeearth-wind-and-fire:~ grahamellis$ perl pat 10 20 49 329 20 10, 20, 49, 329, 20 earth-wind-and-fire:~ grahamellis$ cat pat @vals = (10,20,49,329,20); print ("@vals\n"); print (join(", ",@vals),"\n"); earth-wind-and-fire:~ This page is a thread posted to the opentalk forum
at www.opentalk.org.uk and
archived here for reference. To jump to the archive index please
follow this link.
|
| ||||||||||
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho |