Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I have data like
No:111
Name:aaaa
No:222
Name:bbb
No:333
Name:ccc
No:444
Name:ddd
The result, I need
No | Name |
---|---|
111 | aaaa |
222 | bbb |
333 | ccc |
444 | ddd |
Hope someone help me
Thanks
like this?
tmp:
load rowno() as Id, subfield(row, ':', 2) as Field inline [
row
No:111
Name:aaaa
No:222
Name:bbb
No:333
Name:ccc
No:444
Name:ddd
];
final:
load Id, Field as No Resident tmp where Odd(Id);
join (final) load Id -1 as Id, Field as Name Resident tmp where not Odd(Id);
drop table tmp;
Script:
Table:
LOAD * Inline [
No., Name
111, aaaa
222, bbb
333, ccc
444, ddd
];
Output:
I need to loop through the data automaticaly
Not sure I understand what you mean. Can you elaborate your requirement?
if we have thousand of rows,
for example:
Loop through from first line to end
Loop start
take No(111)
take Name
Loop end(aaaa)
after 222 etc..
Why do you need to loop, why can't you do a simple load? Is data structured in a way that a regular load won't work? You need to provide some details in order to get what you are looking for.
Best,
Sunny
I have external notepad file having data like
No:111
Name:aaaa
No:222
Name:bbb
No:333
Name:ccc
No:444
Name:ddd
etc.....
I have to load all data into table.
The table with columns like
No,Name
111,aaaa
222,bbb
.
.
etc....
if we give the notepad file path, The data should loaded automatically and generate the table as I expected.
Thanks
like this?
tmp:
load rowno() as Id, subfield(row, ':', 2) as Field inline [
row
No:111
Name:aaaa
No:222
Name:bbb
No:333
Name:ccc
No:444
Name:ddd
];
final:
load Id, Field as No Resident tmp where Odd(Id);
join (final) load Id -1 as Id, Field as Name Resident tmp where not Odd(Id);
drop table tmp;
Now its working .
Thanks to all
Pav
If you got what you wanted, please mark Massimo's answer as correct answer to close this thread.
Best,
Sunny