Multi record


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Multi record
# 1  
Old 06-26-2009
Multi record

I have fixed width source file data look like this,

J510111112222
J5102ABCD
J510133334444
J5102EFGH

I want to make this like

11112222J510111112222
11112222J5102ABCD
33334444J510133334444
33334444J5102EFGH

Bolded is the record type.
Thanks for help.
saravanamr
# 2  
Old 06-26-2009
What have you tried?

---------- Post updated at 10:48 AM ---------- Previous update was at 10:42 AM ----------

Try...
Code:
awk '{s=substr($0,6,length($0));print s$0;getline; print s$0}' inputfile

# 3  
Old 06-26-2009
Thanks for ur reply...
but it is not working...
this is the original data

F51010141TK1070000483L4058S462 34329094 0232384840 381892 182 5690
F51020141FIRST CLEARING, LLC A/C 3432-9094
F51030141JOHAN HOLMQVIST YVSTANGSVAGEN 6
F51040141VALBO 81892 SWEDEN AIRMAIL 000000000
F51090141 0000 0
F51010141TK1070000443L4058T155 86374984 0232384840 4 182 5690
F51020141FIRST CLEARING, LLC A/C 8637-4984
F51030141CONFIDENTIAL & CONFIDENTIAL JT TEN
F510401412801 MARKET STREET SAINT LOUIS MO 63103



This is wt am getting
34329094 0232384840 381892 182 F51010141TK1070000483L4058S462 34329094 0232384840 381892 182 5690
34329094 0232384840 381892 182 F51020141FIRST CLEARING, LLC A/C 3432-9094
YVSTANGSVAGEN 6F51030141JOHAN HOLMQVIST YVSTANGSVAGEN 6
YVSTANGSVAGEN 6F51040141VALBO 81892 SWEDEN AIRMAIL 000000000
0000 0F51090141 0000 0
0000 0F51010141TK1070000443L4058T155 86374984 0232384840 4 182 5690
A/C 8637-4984F51020141FIRST CLEARING, LLC A/C 8637-4984
A/C 8637-4984F51030141CONFIDENTIAL & CONFIDENTIAL JT TEN
SAINT LOUIS MO 63103F510401412801 MARKET STREET SAINT LOUIS MO 63103
SAINT LOUIS MO 63103
saravanamr
# 4  
Old 06-26-2009
Quote:
Originally Posted by saravanamr
Thanks for ur reply...
but it is not working...
this is the original data

F51010141TK1070000483L4058S462 34329094 0232384840 381892 182 5690
F51020141FIRST CLEARING, LLC A/C 3432-9094
F51030141JOHAN HOLMQVIST YVSTANGSVAGEN 6
F51040141VALBO 81892 SWEDEN AIRMAIL 000000000
F51090141 0000 0
F51010141TK1070000443L4058T155 86374984 0232384840 4 182 5690
F51020141FIRST CLEARING, LLC A/C 8637-4984
F51030141CONFIDENTIAL & CONFIDENTIAL JT TEN
F510401412801 MARKET STREET SAINT LOUIS MO 63103



This is wt am getting
34329094 0232384840 381892 182 F51010141TK1070000483L4058S462 34329094 0232384840 381892 182 5690
34329094 0232384840 381892 182 F51020141FIRST CLEARING, LLC A/C 3432-9094....

I get this....and I believe this is what you wanted earlier... Please share the detailed requirement.
Code:
0141TK1070000483L4058S462 34329094 0232384840 381892 182 5690F51010141TK1070000483L4058S462 34329094 0232384840 381892 182 5690
0141TK1070000483L4058S462 34329094 0232384840 381892 182 5690F51020141FIRST CLEARING, LLC A/C 3432-9094
0141JOHAN HOLMQVIST YVSTANGSVAGEN 6F51030141JOHAN HOLMQVIST YVSTANGSVAGEN 6
0141JOHAN HOLMQVIST YVSTANGSVAGEN 6F51040141VALBO 81892 SWEDEN AIRMAIL 000000000
0141 0000 0F51090141 0000 0
0141 0000 0F51010141TK1070000443L4058T155 86374984 0232384840 4 182 5690
0141FIRST CLEARING, LLC A/C 8637-4984F51020141FIRST CLEARING, LLC A/C 8637-4984
0141FIRST CLEARING, LLC A/C 8637-4984F51030141CONFIDENTIAL & CONFIDENTIAL JT TEN
01412801 MARKET STREET SAINT LOUIS MO 63103F510401412801 MARKET STREET SAINT LOUIS MO 63103
01412801 MARKET STREET SAINT LOUIS MO 63103

How would I know you have more than just 01, 02 record type and you still have not shared the output you want and on what basis, it should be generated. A detailed requirement will help you and us more.

Last edited by rakeshawasthi; 06-26-2009 at 03:15 AM.. Reason: Requirement not clear
# 5  
Old 06-26-2009
I have this data now,(Bolded is the primary key for each set and I want that to be included on the corresponding consecutive rows)

F51010141TK1070000483L4058S462 34329094 0232384840 381892 182 5690
F51020141FIRST CLEARING, LLC A/C 3432-9094
F51030141JOHAN HOLMQVIST YVSTANGSVAGEN 6
F51040141VALBO 81892 SWEDEN AIRMAIL 000000000
F51090141 0000 0
F51010141TK1070000443L4058T155 86374984 0232384840 4 182 5690
F51020141FIRST CLEARING, LLC A/C 8637-4984
F51030141CONFIDENTIAL & CONFIDENTIAL JT TEN
F510401412801 MARKET STREET SAINT LOUIS MO 63103

and I wanted it to be

A4058S462 34329094 F51010141TK1070000483A4058S462 34329094 0232384840 381892 182 5690
A4058S462 34329094 F51020141FIRST CLEARING, LLC A/C 3432-9094
A4058S462 34329094 F51030141JOHAN HOLMQVIST YVSTANGSVAGEN 6
A4058S462 34329094 F51040141VALBO 81892 SWEDEN AIRMAIL 000000000
A4058S462 34329094 F51090141 0000 0
L4058T155 86374984 F51010141TK1070000443L4058T155 86374984 0232384840 4 182 5690
L4058T155 86374984 F51020141FIRST CLEARING, LLC A/C 8637-4984
L4058T155 86374984 F51030141CONFIDENTIAL & CONFIDENTIAL JT TEN
L4058T155 86374984 F510401412801 MARKET STREET SAINT LOUIS MO 63103

Thanks

---------- Post updated at 02:29 AM ---------- Previous update was at 02:23 AM ----------

F51010141TK1070000483L4058S462 34329094 0232384840 381892 182 5690
F51020141FIRST CLEARING, LLC A/C 3432-9094
F51030141JOHAN HOLMQVIST YVSTANGSVAGEN 6
F51040141VALBO 81892 SWEDEN AIRMAIL 000000000
F51090141 0000 0
F51010141TK1070000443L4058T155 86374984 0232384840 4 182 5690
F51020141FIRST CLEARING, LLC A/C 8637-4984
F51030141CONFIDENTIAL & CONFIDENTIAL JT TEN
F510401412801 MARKET STREET SAINT LOUIS MO 63103

Bolded is the record type, like wise each set mite have 01 to 12...so I have to append the primary key as mentioned earlier till I reach next 01 to 12...
saravanamr
# 6  
Old 06-26-2009
I am again confused, in the first record, key changes from L to A... but not the second time...
And where the code that you have tried?
# 7  
Old 06-26-2009
oh ...sorry ...it is not changing from L to A ..it is A only...

Dude,

lemme explain in simple form, data looks like this,

F5101xxxxA4058S462 34329094
F5102
F5108 asdasd
F5101yyyyL4058T155 86374984
F5104
F5112 sdsd

Pink color is one set and green is another set.
Now i want the primary key to be added like,
A4058S462 34329094 F5101xxxxA4058S462 34329094
A4058S462 34329094 F5102
A4058S462 34329094 F5108 asdasd
L4058T155 86374984 F5101yyyyL4058T155 86374984
L4058T155 86374984 F5104
L4058T155 86374984 F5112 sdsd

The actual position of primary key is 22-30 & 32-51...it is fixed width file.
Thanks
saravanamr
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help with reformat single-line multi-fasta into multi-line multi-fasta

Input File: >Seq1 ASDADAFASFASFADGSDGFSDFSDFSDFSDFSDFSDFSDFSDFSDFSDFSD >Seq2 SDASDAQEQWEQeqAdfaasd >Seq3 ASDSALGHIUDFJANCAGPATHLACJHPAUTYNJKG ...... Desired Output File >Seq1 ASDADAFASF ASFADGSDGF SDFSDFSDFS DFSDFSDFSD FSDFSDFSDF SD >Seq2 (4 Replies)
Discussion started by: patrick87
4 Replies

2. Shell Programming and Scripting

Need code for updating second record to first record in shell scripting

Hi,, I have requirement that i need to get DISTINCT values from a table and if there are two records i need to update it to one record and then need to submit INSERT statements by using the updated value as a parameter. Here is the example follows.. SELECT DISTINCT ID FROM OFFER_GROUP WHERE... (1 Reply)
Discussion started by: Samah
1 Replies

3. Programming

Multi head/multi window hello world

I am trying to write a large X app. I have successfully modified my xorg.conf to setup 4 monitors on an NVIDIA Quatro5200. I am trying to modify a simple hello world application to open a window on three of the four monitors. depending on the changes to loop the window creation section and event... (2 Replies)
Discussion started by: advorak
2 Replies

4. Shell Programming and Scripting

Extract timestamp from first record in xml file and it checks if not it will replace first record

I have test.xml <emp><id>101</id><name>AAA</name><date>06/06/14 1811</date></emp> <Join><id>101</id><city>london</city><date>06/06/14 2011</date></join> <Join><id>101</id><city>new york</city><date>06/06/14 1811</date></join> <Join><id>101</id><city>sydney</city><date>06/06/14... (2 Replies)
Discussion started by: vsraju
2 Replies

5. Shell Programming and Scripting

How to compare current record,with next and previous record in awk without using array?

Hi! all can any one tell me how to compare current record of column with next and previous record in awk without using array my case is like this input.txt 0 32 1 26 2 27 3 34 4 26 5 25 6 24 9 23 0 32 1 28 2 15 3 26 4 24 (7 Replies)
Discussion started by: Dona Clara
7 Replies

6. Shell Programming and Scripting

How to substract selective values in multi row, multi column file (using awk or sed?)

Hi, I have a problem where I need to make this input: nameRow1a,text1a,text2a,floatValue1a,FloatValue2a,...,floatValue140a nameRow1b,text1b,text2b,floatValue1b,FloatValue2b,...,floatValue140b look like this output: nameRow1a,text1b,text2a,(floatValue1a - floatValue1b),(floatValue2a -... (4 Replies)
Discussion started by: nricardo
4 Replies

7. Shell Programming and Scripting

Reject the record if the record in the next line does not satisfy the pattern

Hi, I have a input file with the following entries: 1one 2two 3three 1four 2five 3six 1seven 1eight 1nine 2ten The output should be 1one 2two 3three 1four 2five 3six (2 Replies)
Discussion started by: supchand
2 Replies

8. Shell Programming and Scripting

Multi Record Layout

I have a fixed width source file like this( it has 5 different record types identified by bolded numbers) N5101ABCD 9820398 2983287 N5102 9s9923 00000000 00 N5103 N5101TTT 9843438 9494994 N5104 sdsd N5101YYY 7777777 1111111 I need to have like this: N5101ABCD ... (2 Replies)
Discussion started by: saravanamr
2 Replies

9. UNIX for Dummies Questions & Answers

Multi User Multi Task

Dear Experts Why we always hear that unix operating system is Multi User and Multi task. What does these two means. I have looked at some books and documents but couldn't find aclear explenation. Can we say Windows operating system is also multi user and multi task?? Thanks for your help in... (6 Replies)
Discussion started by: Reza Nazarian
6 Replies

10. UNIX for Dummies Questions & Answers

multi-file multi-edit

Good day! I am trying to learn how to use the "sed" editor, to perform multiple edits on multiple files in multiple directories. I have one script that tries to call up each file and process it according to the edits listed in a second script. I am using a small input text to test these, at... (12 Replies)
Discussion started by: kielitaide
12 Replies
Login or Register to Ask a Question