Hi, I have this front end CSS data stored in a web page. Here is the data in csv file.
I need to convert this text file into the below format. once, i convert it to below format, i will be able to display it on the front end. this format below is used to display data in jqgrid.secid,Initial_shares 002826,3777 0028262,3777 0028262,3777 0028262,3777 0028262,3777 0028262,3777
In order to convert the text to above format, i have used the below perl code. Please note. This conversion is static. i.e. it knows how many columns are there. In this case, there will be 2 columns. secid and Initial_shares. so here is the static code.var secid = [ "002826", "0028262", "0028262", "0028262", "0028262", +"0028262"]; var Initial_shares = [ "3777", "3777", "3777", "3777", "3777", "3777"1 ];
The @perl_array will be then exactly similar to the kind of data we were expecting at the start. i wil transfer this perl variable to front end for displaying then. I need help in the following case. What if instead of 2 columns, there are 5 columns. How can we convert the same csv file to the format mentioned earlier. it should be all dynamic. Can someone shed some light please.my @a=(); my @b=(); my @a1=(); my @b1=(); my @perl_array=(); my @filena = split(/\|/, $filename); open (TXT, "<$filename") || die "Can't open $filename: $!\n"; while (my $line=<TXT>) { chomp($line); ($a2, $b2) = split /,/, $line; push @a,('"',"$a2",'"',','); push @b,('"',"$b2",'"',','); } splice @a,0,4; #this splice is used to remove the header name. i.e. +first row data- secid, Initial_shares splice @b,0,4; push @a1,"var secid=[@a]"; push @b1,"var Initial_shares=[@b]"; push @perl_array, "@a1; @b1"; close TXT;
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |