Improper wrapping of text in split of file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Improper wrapping of text in split of file
# 1  
Old 12-03-2010
Improper wrapping of text in split of file

Hi
I am using shell script where I am calling SQLPLUS and executing one PL/SQL block.

This PL/SQL block generates the spool file for example splfile.txt.
After successful generation of spool file I use nawk to split this file into 2 different files. Till here no issues.

[I use following syntax to split file]

Code:
 
nawk -F"|" -v var1="${v_project}" -v var2="${v_net}" -v var3="${v_path}" '{
fn=var3 "/ABS_" (length($1)==2?"AAAA":"BBBB") "_" var1 "_" var2 ".txt"
print > fn
}' ${v_path}/spoolfile.txt

In one of the split file where the fields are seperated by pipe '|' delimiter having issue with wrapping the text into next line and
eating up the spaces which results in incorrect output format

Actual required format is:-
AA|999999999|111|222|11-22|2|AAAAAAAAAAAAAAA |4444 g. ttttttt |ffffff 229292-s-2-222 |888888|yyyy hhhh | | |yyyy/mm/dd| | | |3|7777777777|asjhasjdhjdjasjhg|666|333| | |
AA|999999999|111|222|11-22|2|AAAAAAAAAAAAAAA |4444 g. ttttttt |ffffff 229292-s-2-222 |888888|yyyy hhhh | | |yyyy/mm/dd| | | |3|7777777777|asjhasjdhjdjasjhg|666|333| | |

Example of output in SQL plus in windows environment (i.e the file generated in windows environment)
AA|999999999|111|222|11-22|2|AAAAAAAAAAAAAAA |4444 g. ttttttt |ffffff 229292-s-2-222 |888888|yyyy hhhh | | |yyyy/mm/dd| | | |3|7777777777|asjhasjdhjdjasjhg|666|333| | |

In Unix Environment
AA|999999999|111|222|11-22|2|AAAAAAAAAAAAAAA |4444 g. ttttttt |ffffff 229292-s-2-222 |888888|yyyy hhhh | | |yyyy/mm/dd| | ||3|7777777777|asjhasjdhjdjasjhg|666|333| | |

I am putting both one after another for easy comparison
AA|999999999|111|222|11-22|2|AAAAAAAAAAAAAAA |4444 g. ttttttt |ffffff 229292-s-2-222 |888888|yyyy hhhh | | |yyyy/mm/dd| | | |3|7777777777|asjhasjdhjdjasjhg|666|333| | |
AA|999999999|111|222|11-22|2|AAAAAAAAAAAAAAA |4444 g. ttttttt |ffffff 229292-s-2-222 |888888|yyyy hhhh | | |yyyy/mm/dd| | ||3|7777777777|asjhasjdhjdjasjhg|666|333| | |

Actually from 8th filed the line is wrapping into next line (so I see some spaces are eaten up) again in 17th column space is eaten up
I doub't the carriage return is eating up the spaces or I am doing something wrong or there is some other way to this ?? I am clueless here ...
(Before I spool the file, I am setting the required LINESIZE in SQLPLUS i.e. SET LINESIZE xxx)

I should say thanks to those who read my above problem patiently......

Please let me know if I am not clear on any of the above lines ....so that I can tell in more detail to make it clear

Regards
JC

---------- Post updated at 12:51 PM ---------- Previous update was at 12:44 PM ----------

I think code is not wrapped correctly ...

Actual required format is:-
PHP Code:
AA|999999999|111|222|11-22|2|AAAAAAAAAAAAAAA                                   |4444 gttttttt                                   |ffffff 229292-s-2-222                             |888888|yyyy hhhh           |          |  |yyyy/mm/dd| | | |3|7777777777|asjhasjdhjdjasjhg|666|333|  | |
AA|999999999|111|222|11-22|2|AAAAAAAAAAAAAAA                                   |4444 gttttttt                                   |ffffff 229292-s-2-222                             |888888|yyyy hhhh           |          |  |yyyy/mm/dd| | | |3|7777777777|asjhasjdhjdjasjhg|666|333|  | | 
Example of output in SQL plus in windows environment (i.e the file generated in windows environment)
PHP Code:
AA|999999999|111|222|11-22|2|AAAAAAAAAAAAAAA                                   |4444 gttttttt                                   |ffffff 229292-s-2-222                             |888888|yyyy hhhh           |          |  |yyyy/mm/dd| | | |3|7777777777|asjhasjdhjdjasjhg|666|333|  | | 
In Unix Environment
PHP Code:
AA|999999999|111|222|11-22|2|AAAAAAAAAAAAAAA                                   |4444 gttttttt          |ffffff 229292-s-2-222                             |888888|yyyy hhhh           |          |  |yyyy/mm/dd| | ||3|7777777777|asjhasjdhjdjasjhg|666|333|  | | 
I am putting both one after another for easy comparison
PHP Code:
AA|999999999|111|222|11-22|2|AAAAAAAAAAAAAAA                                   |4444 gttttttt                                   |ffffff 229292-s-2-222                             |888888|yyyy hhhh           |          |  |yyyy/mm/dd| | | |3|7777777777|asjhasjdhjdjasjhg|666|333|  | |
AA|999999999|111|222|11-22|2|AAAAAAAAAAAAAAA                                   |4444 gttttttt          |ffffff 229292-s-2-222                             |888888|yyyy hhhh           |          |  |yyyy/mm/dd| | ||3|7777777777|asjhasjdhjdjasjhg|666|333|  | | 
# 2  
Old 12-04-2010
FYI there is not only LINESIZE that can be set setup (in sqlplus), you could for example also have a look at some of the following "trim" and other "wrap" stuff below and play with different values of these options and change or adapt it to fit your needs

Code:
set array 100
set pages 0
set wrap off
set flush off
set feed off
set feedback off
set echo off
set verify off
set term off
set head off
set trim on
set colsep "|"
set linesize 800

do you need those blank stuff ?
Why don't you just remove all space and tabs in all of them (or at least those that are accolate to a | delimiter)

Last edited by ctsgnb; 12-04-2010 at 12:09 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Split the text file into two

OS : RHEL 7.3 I have a file like below. I want to move (cut and paste) the first 7 lines of file1 to another file (file2). How can I do this ? In my real life scenario, I will be moving first 12 millions lines of file1 to file2 $ cat file1.txt 7369|SMITH |CLERK | ... (5 Replies)
Discussion started by: kraljic
5 Replies

2. Shell Programming and Scripting

How to target certain delimiter to split text file?

Hi, all. I have an input file. I would like to generate 3 types of output files. Input: LG10_PM_map_19_LEnd_1000560 LG10_PM_map_6-1_27101856 LG10_PM_map_71_REnd_20597718 LG12_PM_map_5_chr_118419232 LG13_PM_map_121_24341052 LG14_PM_1a_456799 LG1_MM_scf_5a_opt_abc_9029993 ... (5 Replies)
Discussion started by: huiyee1
5 Replies

3. Shell Programming and Scripting

Split a text file into multiple pages based on pattern

Hi, I have a text file (attached the sample). I have also, attached the way the way the files need to be split. We get this file, that will either have 24 Jurisdictions, or will miss some and retain some. Like in the attached sample file, there are only Jurisdictions 03,11,14,15, 20 and 30.... (3 Replies)
Discussion started by: ebsus
3 Replies

4. Shell Programming and Scripting

Split a text file into multiple text files?

I have a text file with entries like 1186 5556 90844 7873 7722 12 7890.6 78.52 6679 3455 9867 1127 5642 ..N so many records like this. I want to split this file into multiple files like cluster1.txt, cluster2.txt, cluster3.txt, ..... clusterN.txt. (4 Replies)
Discussion started by: sammy777
4 Replies

5. Shell Programming and Scripting

Split column using awk in a text file

chr1 412573 . A C 2758.77 . AC=2;AF=1.00;AN=2;DP=71;Dels=0.00;FS=0.000;HaplotypeScore=2.8822;MLEAC=2;MLEAF=1.00;MQ=58.36;MQ0=0;QD=38.86;resource.EFF=INTERGENIC(MODIFIER||||||||) GT:AD:DP:GQ:PL 1/1:0,71:71:99:2787,214,0 GATKSAM chr1 602567 rs21953190 A ... (9 Replies)
Discussion started by: mehar
9 Replies

6. Shell Programming and Scripting

wrapping text not exceeding 80 characters

I have a file where the text might exceed 80 characters. I want to have the maximum text lengths to be 80, and cut text from a space. I written an awk script below but does not seem to work very well { gsub("\t"," ") $0 = line $0 while (length <= WIDTH) { line = $0 ... (3 Replies)
Discussion started by: kristinu
3 Replies

7. Shell Programming and Scripting

Split text file

Hi all, I am very new to shell scripting and some help is greatly appreciated. I have 10 column based text files, i would like to split each of them into 6 files ; the 1st one having columns 1, 2 ,3,4 , the second one having columns 1,2,8,9 etc. Is there a way I could get 60 files out my... (3 Replies)
Discussion started by: shreymuk
3 Replies

8. Shell Programming and Scripting

Perl Split for text in file

Hi all I have written Perl script to swap the strings in the second a third column from a text file. My input file format is : the|empty|the|det lake|empty|lake|conj_and was|empty|was|auxpass drained|empty|drained|conj_and birds|empty|bird|s|nn The expected output file format is... (11 Replies)
Discussion started by: my_Perl
11 Replies

9. Shell Programming and Scripting

efficiently split a 2GB text file into two

Can an expert kindly write an efficient Linux ksh script that will split a large 2 GB text file into two? Here is a couple of sample record from that text file: "field1","field2","field3",11,22,33,44 "TG","field2b","field3b",1,2,3,4 The above rows are delimited by commas. This script is to... (2 Replies)
Discussion started by: ihot
2 Replies

10. UNIX for Dummies Questions & Answers

Split text file by pages

Hello! Firts of all, I'm sorry for my English. My problem: I have text file with few Form Feed symbols (FF, ASCII code =12) inside (for example - some report, consists of some pages for printing). I want to split this text by pages - each page (until FF symbol) in single file. I... (2 Replies)
Discussion started by: ranri
2 Replies
Login or Register to Ask a Question