I am trying to combine columns from multiple text files into a single file using paste command but the record length being unequal in the different files the data is running over to the closest empty cell on the left. Please see below.
What can i do to resolve this ?
File 1 File 2 File3 File4
A 1 X 7
B 2 Y 8
C 3 9
D 4 10
E 5
6
Desired Output
Final File
Column1 Column2 Column3 Column4
A 1 X 7
B 2 Y 8
C 3 9
D 4 10
E 5
6
Current Output
Column1 Column2 Column3 Column4
A 1 X 7
B 2 Y 8
C 3 9
D 4 10
E 5
6
Your current output and desired output look same.
Also you didn't mention the inputs completely. Pls mention sample of each file content, expected out, current output, the command you are tried.
Are you sure you didn't inadvertently swapped the desired result with current result? If the result of the paste is not what you want, you can pipe it to
Maybe you should add empty lines to your files (especially File3) until your file has the same number of lines than the longer one (MaxLine), before performing the paste command
I did not swap. The formatting got removed. The desired one is to have the output with higher records on the right stay even after pasting unlike now where it is moving over to left column.
---------- Post updated at 04:28 PM ---------- Previous update was at 04:26 PM ----------
ctsgnb
May be adding empty lines is not an option as output is coming from Oracle DB.
I am redirecting the oracle db output to text files and then want to combine the text files into a csv file. For this i am printing a comma at the end of each record. This works fine until all files have equal no. of records but when the records for file on the left is less than the file on the right then records from right side file spill over to the left.
As ctsgnb pointed out, you should use SQL to directly generate the desired result. I am sure this can be done in SQL simpler and more efficiently. It's probably just a simpler joins of four tables. Give us your tables and data, if nobody here can help, you can ask the people in the pl/sql forum of Welcome to The Oracle FAQ | Oracle FAQ.