Column to row conversion using script
Hello,
I am in need of a script to convert a file having 1 column to rows.
e.g
File is having entries like below
1
2
3
4
5
And I want to convert them like below.
1 2 3 4 5
Can any body help me on this ?
Thank you
Regards,
~Anoop
Please show what you type.
I test my example.
For 10st post
#!/bash - This line must present
For my example - attantion - first comannd printf
You result look like you type print
Regards.
Edited by: Nik on 28.06.2011 11:44
Similar Messages
-
Problem in displaying the data of columns into rows in sap script
hi,
i am working on a sap script and i have to display the dat which is displayed in column into rows but it is not displaying it properly.
eg, C
12.1
Si
5.5
it is displaying the data right now like this but i want to display the data like this:-
eg, C Si
12.1 5.5
plzzprovide me guidelines how to solve this problem.hi,
i am using this code to display the data:-
plzz provide me guidelines where i am getting wrong?
TOPparCOMPONENT DESP,,,,,, INS. LOT #, , , , , , MIC,,,,,,,,,, MIC VALUEparENDTOPparFINAL
PROTECT
IF &I_FINAL-PRUEFLOS& NE '000000000000'
&I_FINAL-MAKTX(23)&&i_final-prueflos(12Z)&
&I_FINAL-kurztext(25)&
&I_FINAL-original_input(8)&
ELSE
&I_FINAL-MAKTX(23)&
&I_FINAL-kurztext(25)&
&I_FINAL-original_input(8)&
ENDIF
ENDPROTECT
ITEMHEAD
POSITION WINDOW
SIZE WIDTH +0 . 4 CH HEIGHT +1 LN
BOX FRAME 10 TW
BOX HEIGHT '1.35' LN INTENSITY 20
IF &PAGE& = '1'
BOX XPOS '0' CH YPOS '0' CM WIDTH '0' CM HEIGHT '43' LN FRAME '10' TW
For horizontal line at top
BOX XPOS '0' CH YPOS '0' CM WIDTH '75' CH HEIGHT '0' LN FRAME '10' TW
COLUMN LINES...
END OF COLUMN LINES...
BOX XPOS '0' CH YPOS '43' LN WIDTH '75' CH HEIGHT '0' LN FRAME '10'TW
BOX XPOS '75' CH YPOS '0' LN WIDTH '0' CH HEIGHT '43' LN FRAME '10'TW
ELSE
COLUMN LINES...
END OF COLUMN LINES...
BOX XPOS '0' CH YPOS '0' CM WIDTH '0' CM HEIGHT '47' LN FRAME '10' TW
BOX XPOS '0' CH YPOS '0' CM WIDTH '75' CH HEIGHT '0' LN FRAME '10' TW
BOX XPOS '0' CH YPOS '0' CM WIDTH '45' CM HEIGHT '0' LN FRAME '10' TW
BOX XPOS '20' CH YPOS '0' CM WIDTH '0' CM HEIGHT '47' LN FRAME '10' TW
BOX XPOS '0' CH YPOS '47' LN WIDTH '75' CH HEIGHT '0' LN FRAME '10'TW
BOX XPOS '75' CH YPOS '0' LN WIDTH '0' CH HEIGHT '47' LN FRAME '10'TW
ENDIF
LINEFEED
NEWPAGE
NEW-PAGE
provide me guidelines to solve this problem.
Edited by: ricx .s on Mar 13, 2009 5:58 AM -
hiii,
I have a table which has 14 rows & 8 cols.
I want covert it into 14 cols & 8 rows,
by using sql how to do it..pls help me.Oracle Database Search Results: pivot
-
Dynamic internal table- column to row conversion
Hello all,
Inside a program i generate a dynamic internal table and
This table has one single column. But I need to convert the rows as columns.
Eg:
dynamic internal table ITAB has content
Forbes
Times
Reuters
Warner
stern
I would like to have a ITAB2 like this
Forbes Times Reuters Warner Stern
Please note this is a Dynamic internal table!!!!
I need some approach for my problem. Thanks a lot in advance.
Karthik.Hi karthik,
1.
For this purpose,
in my program,
<b> there is an INDEPENDENT FORM</b>
whose inputs are
<b> LIST OF FIELDS, (just as u require)</b>
and from those, it consructs dynamic table.
2. Here is the program.
the dynamic table name will be
<DYNTABLE>.
3. U can use this program (FORM in this program)
to generate any kind of internal table
by specifying list of fields.
4.
REPORT abc.
COMPULSORY
FIELD-SYMBOLS: <dyntable> TYPE ANY TABLE.
FIELD-SYMBOLS: <dynline> TYPE ANY.
DATA: lt TYPE lvc_t_fcat.
DATA: ls TYPE lvc_s_fcat.
FIELD-SYMBOLS: <fld> TYPE ANY.
DATA : fldname(50) TYPE c.
DATA : ddfields LIKE ddfield OCCURS 0 WITH HEADER LINE.
START-OF-SELECTION.
field list
ddfields-fieldname = 'BUKRS'.
APPEND DDFIELDS.
ddfields-fieldname = 'MATNR'.
APPEND DDFIELDS.
PERFORM mydyntable .
see <DYNTABLE> in debug mode.
BREAK-POINT.
INDEPENDENT FORM
FORM mydyntable .
Create Dyn Table From FC
FIELD-SYMBOLS: <fs_data> TYPE REF TO data.
FIELD-SYMBOLS: <fs_1>.
FIELD-SYMBOLS: <fs_2> TYPE ANY TABLE.
DATA: lt_data TYPE REF TO data.
data : lt TYPE lvc_t_fcat .
CONSTRUCT FIELD LIST
LOOP AT ddfields.
ls-fieldname = ddfields-fieldname.
APPEND ls TO lt.
ENDLOOP.
ASSIGN lt_data TO <fs_data>.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = lt
IMPORTING
ep_table = <fs_data>
EXCEPTIONS
generate_subpool_dir_full = 1
OTHERS = 2.
IF sy-subrc <> 0.
ENDIF.
Assign Dyn Table To Field Sumbol
ASSIGN <fs_data>->* TO <fs_1>.
ASSIGN <fs_1> TO <fs_2>.
ASSIGN <fs_1> TO <dyntable>.
ENDFORM. "MYDYNTABLE
regards,
amit m. -
Need help on Unpivot (Columns to rows conversion)
Could you please help me to do unpivot using sql?
Table creation and insertion scripts:
create table REQ
ID NUMBER,
VALUE VARCHAR2(20)
insert into REQ (ID, VALUE)
values (1, 'HI,HELLO, KARTHI');
insert into REQ (ID, VALUE)
values (2, 'ARE,YOU,FINE,BHAR');
insert into REQ (ID, VALUE)
values (3, '100,200,300');
commit;
I need to view the data in the below format
ID VALUE
1 HI
1 HELLO
1 KARTHI
2 ARE
2 YOU
2 FINE
2 BHAR
3 100
3 200
3 300However, I would take care on the performance issue.So let's use the model clause:
SQL> set autotrace on
SQL> select id
2 , v
3 from req
4 model
5 partition by (id)
6 dimension by (0 i)
7 measures (value v)
8 rules iterate (10) until (instr(v[iteration_number+1],',') = 0)
9 ( v[iteration_number+1] = substr(v[iteration_number],instr(v[iteration_number],',')+1)
10 , v[iteration_number] = substr(v[iteration_number],1,instr(v[iteration_number],',')-1)
11 )
12 order by id
13 , i
14 /
ID V
1 HI
1 HELLO
1 KARTHI
2 ARE
2 YOU
2 FINE
2 BHAR
3 100
3 200
3 300
10 rijen zijn geselecteerd.
Uitvoeringspan
0 SELECT STATEMENT Optimizer=ALL_ROWS (Cost=3 Card=3 Bytes=75)
1 0 SORT (ORDER BY) (Cost=3 Card=3 Bytes=75)
2 1 SQL MODEL (ORDERED FAST) (Cost=3 Card=3 Bytes=75)
3 2 TABLE ACCESS (FULL) OF 'REQ' (TABLE) (Cost=2 Card=3 By
tes=75)
Statistics
48 recursive calls
0 db block gets
11 consistent gets
0 physical reads
0 redo size
528 bytes sent via SQL*Net to client
271 bytes received via SQL*Net from client
6 SQL*Net roundtrips to/from client
1 sorts (memory)
0 sorts (disk)
10 rows processedRegards,
Rob. -
I would like to convert rows to columns of a sql.
select col1, col2, col3, col4
ABC 1 2 3
DEF 4 5 6
GHI 7 8 9
I want to convert to
ABC DEF GHI
1 4 7
2 5 8
3 6 9
Thanks for your response.select regexp_substr( col1,'[^\,]+',1,1) column1,
regexp_substr( col1,'[^\,]+',1,2) column2,
regexp_substr( col1,'[^\,]+',1,3) column3
from (
WITH t AS
(select 'ABC' col1, 1 col2, 2 col3, 3 col4 from dual union
select 'DEF', 4, 5, 6 from dual union
select 'GHI', 7, 8, 9 from dual
SELECT substr(SYS_CONNECT_BY_PATH (col1, ' ,'),2) col1
FROM (SELECT col1,
ROW_NUMBER () OVER ( ORDER BY COl1) rn
FROM t)
WHERE connect_by_isleaf = 1
START WITH rn = 1
CONNECT BY PRIOR rn = rn - 1
union all
SELECT substr(SYS_CONNECT_BY_PATH (col2, ' ,'),2) col2
FROM (SELECT col2,
ROW_NUMBER () OVER ( ORDER BY COl2) rn
FROM t)
WHERE connect_by_isleaf = 1
START WITH rn = 1
CONNECT BY PRIOR rn = rn - 1
union all
SELECT substr(SYS_CONNECT_BY_PATH (col3, ' ,'),2) col3
FROM (SELECT col3,
ROW_NUMBER () OVER ( ORDER BY COl3) rn
FROM t)
WHERE connect_by_isleaf = 1
START WITH rn = 1
CONNECT BY PRIOR rn = rn - 1
union all
SELECT substr(SYS_CONNECT_BY_PATH (col4, ' ,'),2) col4
FROM (SELECT col4,
ROW_NUMBER () OVER ( ORDER BY COl4) rn
FROM t)
WHERE connect_by_isleaf = 1
START WITH rn = 1
CONNECT BY PRIOR rn = rn - 1
) t1 -
Multiple columns and rows update using select staement
i am trying to update the 2 colums of a table based on the cursor result set with key values are matching.
DECLARE
CURSOR update_master
IS
SELECT B.cust_num,c.cust_num,
B.cust_name,B.cust_bal
FROM
Table_one B
JOIN
Table_two C
ON B.cust_num= C.cust_num;
BEGIN
FOR master_rec IN update_master
LOOP
UPDATE Table_three
SET col1 = master_rec.cust_name,
Col2 = master_rec.cust_bal,
Where WHERE Cust_num = master.cust_num;
END LOOP;
COMMIT;
END;
The 3 tables are having around 50000 records individually............
It is taking too much of time to execute......more than 6 minutes......
how can we optimize it?? can we write this update statement directly? instead of writing it in procedure?Here's a general approach:
update some_table s
set (s.col1, s.col2) = (select x.col1, x.col2
from other_table x
where x.key_value = s.key_value
where exists (select 1
from other_table x
where x.key_value = s.key_value
; -
Need some help to display the output data in the below format,Pls help out...
Eg:
OV:Old Value
NV:New Value
ID OV NV
1 -- 100
1 100 200
1 200 300
OUTPUT:
ID VALUES
1 100 200 300Hi,
i think this link helpful to you
http://www.club-oracle.com/forums/unpivoting-column-to-row-conversion-techniques-sql-t145/ -
Hello everyone,
I am developing an application (ALV OO) to select more than 1 column by row ( one ). This is an a holiday application so the idea is:
-One column will be the day, and the row will be the user.
So I am trying to select more than one day by user (that would be the row).
I am using the method set_table_for_first_display but when it shows the alv, doesn't let me to select more than one column with a click of the mouse.
Does anybody know if I can do this (select more than one column, by row) in somehow?
Please let me know if you need more clarification about this.
Thanks in advance
DiegoHi Diego,
it's all in the documentation.
set different selection modes through the value of the field u201CSEL_MODEu201D in the layout structure.
SPACE
same as 'B'
see 'B'
Default setting
'A'
Column and row selection
Multiple columns
Multiple rows
The user selects the rows through pushbuttons at the left border of the grid control.
'B'
Simple selection, list box
Multiple columns
Multiple rows
'C'
Multiple selection, list box
Multiple columns
Multiple rows
'D'
Cell selection
Multiple columns
Multiple rows
Any cells
The user selects the rows through pushbuttons at the left border of the grid control
Beyond setting this option, you can set u201CNO_ROWMARKu201D option to hide the mark column which is normally visible when the selection mode allows multiple row selection.
One point to notice here is that if you set your ALV Grid as to be editable, it may override your selection mode regardless of your layout settings.
This is from SDN Community Contribution "An Easy Reference for ALV Grid Control" By: Serdar ŞİMŞEKLER
Sorry, no link,. it's on my disk.
Regards,
Clemens -
I use "element 12" and want like in the old PS version due Automating and Contact II upload multiple filesand print them with any columns and rows on the same page . How does it work?
Can you supply a link?
-
Using forms to fill columns not rows
Can I use a form to fill columns instead of rows? I have students names in a header column (each student is a different row) and I have assignments in different columns. Can I use a form and have the column info appear at the top with a list of students in the form to fill in grades for that assignment. The way it is now, it shows a single student at the top of the forum and all the assignments in the fill form. I want the opposite. I really don't want to create a column with a different student in each one. Too long of a table.
I did that for 2 hours last night and found out the sort doesn't work on the table with the references, so that meant on the form, nothing was sorted right (I have four fields I have to sort by depending on what I am doing). I tried creating a master table that I could sort, but the data table that the forms feed into won't sort. I ended up realizing that even though you can reference the cell of another sheet or table, it won't sort when the referred to table is sorted.
Example:
Master table
Bob (in cell A1)
John (in cell A2)
Adam (in cell A3)
Data Table
Bob (referrenced =A1)
John (referrenced =A2)
Adam (referrenced =A3)
Sort the Master Table:
Adam (in A1)
Bob (in A2)
John (in A3)
The data table does this:
Bob (referrenced =A2)
John (referrenced =A3)
Adam (referrenced =A1)
You can see the data table maintains it's original sort order regardless of how the master table is sorted. -
Create a counter for the rows in a table using script editor?
Hi ,
I want to add afield in a particular table with first field is its serial number . How to use scripting editor to fill the serial number ?
How to create a counter ?
Edited by: Rajan.Dexter9 on Jan 30, 2012 9:40 PMHello Rajan,
Create a field in the table and name it as 'SERIAL'. Create a variable called 'count' with default value as 0. Now in script editor, for javascript language and calculate event, write the following script.
var fields = xfa.layout.pageContent(xfa.layout.page(this)-1, "field", 0);
for (var i=0; i <= fields.length-1; i++)
if (fields.item(i).name == "SERIAL")
count.value = count.value + 1;
this.rawValue = count.value; -
Data conversion into specified format using Script component in SSIS 2008
We have a field in the flat file source which is of the format 13399I , and it need to be type cast to the below format.
13399I = 1339.99
5950{ = 595.00
The sign field equals:
{=0
A=1
B=2
C=3
D=4
E=5
F=6
G=7
H=8
I=9
please let us know how to accomplish using script component in SSISYou can use the following in the script task.
1) Create a dictionary to hold the key-value pairs ({=0,A=1...).
2) Use a substring function to pull out all the string minus the last character.
3) Append the last character back after replacing the character with the respective value from the dictionary.
4) Convert the final string to int/decimal/numeric as per the destination.
Do keep in mind, the data you are referring to is in the COMP3 format. You can do some further research regarding how to convert COMP3 to decimal. There are many ways out there. I personally prefer to load the data into a table and us a lookup table
to do all this. But it's entirely by preference. -
How to use Script in ADF model?
Hi!
I don't know how to use Script in ADF model. Help me, please!
Detail: javaScript.
Thanks so much!You can put your Javascript code in the Onmouseover property of the column.
I don't have the Javascript code for changing the color but for example the following will pop up an alert
<af:outputText value="#{row.DepartmentId}" onmouseover="alert(\'Unload event fired!\')"> -
Populate columns with row values in Sql Server Reporting Services
I have got a dataset with 2 columns named Row and Title. There are 8 rows in this dataset and I want to display those 8 titles within columns in a table. So I create a table with 8 columns and set each column's expression to
=LookUp(Fields!Row.Value,1,Fields!Title.Value,"Titles")
=LookUp(Fields!Row.Value,2,Fields!Title.Value,"Titles")
=LookUp(Fields!Row.Value,3,Fields!Title.Value,"Titles")
However only the first column displays a title. The other 7 display nothing. Is my expression wrong?Hi,
Is the row datatype non-numeric? Maybe the lookup is failing for that reason. You coulr try adding a conversion to the field:
=LookUp(cint(Fields!Row.Value),1,Fields!Title.Value,"Titles")
Could you, perhaps, instead use a tablix table and put the Title column on the row group? That would pivot the data the way that you want it.
Mark
Maybe you are looking for
-
Edit font size standard report
Hello community, I try to edit the font size of a standard report but I can't find any menu within APEX to edit this reports. I also tried to edit it within the SQL with '< f o n t s i z e=130%">' || ... || '</ f o n t >' but this did not work. Can a
-
DVD Pro Is EXREMELY SLOW and slow system
I am running DVD Pro Studio on a PowerMac G5 with 4 meg of RAM It is painfully slow... the inspector freezes when I try to show shapes.. loading assets in stills (granted they are big files) is beyond painful frankly I went to a mac to do just this..
-
How many times can i tranfer from iTunes???
I want to buy an ipod Nano but, and 2GB isn't too small for me in short bursts, but I want to know how many times I can transfer music from iTunes to my iPod, so if I delete songs from the iPod I don't have to worry about being able to put them back
-
How Can I Fix A QuickTime Codec Error?
How Can I Fix A QuickTime Codec Error? I have several movies from 2008 that are labeled as .mov but I now get a QuickTime error saying "The document "XXXXXX" could not be opened. A required Codec isn't available." These movies ran in QuickTime just f
-
Load Balancing for Microsoft Orchestrator application
Hi Folks, We are trying to configure Load Balancing for Orchestrator Server. We have closely 200 users running a workflow.. so in that case, we need to configure the Runbook Server as a application load balancing cluster, so please do share me the co