I have a fixed width file of length 53. when is try to get the lengh of the record of that file i get 2 different answers.
The above code gives me length 50.
The above code gives me length 53.
Please clarify on the above.
According to the standards, the awk command given should print the number of characters in the 1st line in the file (not counting the trailing newline). But, some buggy versions (including Mac OS X's awk) of awk print the number of bytes instead of the number of characters.
The meaning of wc -L is not defined by the standards and the man pages I've seen that include this options say that -L gives the length of the longest line, but does not specify the units (bytes, characters, etc.), but with wc i'd expect that the count includes the terminating newline character.
When you say you have a fixed width file of length 53, it isn't clear whether you mean each line in the file is 53 bytes, 53 characters, 53 32-bit integers, etc., or a file that is a single line of 53 bytes, characters, ... If your input is encoded using UTF-8, 53 characters could take 53 to 313 bytes. Without knowing the actual contents of your input file, the encoding used to store characters in the file, what characters are contained in the file, the meaning of wc's -L option on your system, whether awk's length on your system counts bytes of characters, and what locale is being used when running the above commands; there isn't much we can do to diagnose what is going on in your specific case.
Thank u so much .Its working fine as expected.
---------- Post updated at 03:41 PM ---------- Previous update was at 01:46 PM ----------
I need one more help.
I have another file(fixed length) that will get negative value (ex:-00000000003000) in postion (98 - 112) then i have to... (6 Replies)
Hi Guys
I am checking the treads to get the answer but i am not able to get the answer for my question.
I have two files. First file is a pattern file and the second file is the file i want to search in it. Output will be the lines from file2.
File1:
P2797f12af 44751228... (10 Replies)
I am trying to determine what would be a fast and simple way to manipulate data that comes in a fixed width format. This data has 6 segments within a record. Each record needs to written out with a header and the 6 segments. Based on the value in column #6 the fields will be defined accordingly.... (4 Replies)
Hi All,
I have created a script which generates FIXED-WIDTH file by executing Oracle query.
SELECT RPAD(NVL(col1,CHR(9)),20)||NVL(col2,CHR(9))||NVL(col3,CHR(9) FROM XYZ
It generates the data file with proper alignment. But if same file i transfer to windows server or Mainframe... (5 Replies)
Hi, all.
I need to convert a file tab delimited/variable length file in AIX to a fixed lenght file delimited by spaces. This is the input file:
10200002<tab>US$ COM<tab>16/12/2008<tab>2,3775<tab>2,3783
19300978<tab>EURO<tab>16/12/2008<tab>3,28523<tab>3,28657
And this is the expected... (2 Replies)
Hi, I have two input files.
File1:
ID Name Place
1-234~name1~Newyork
1-34~name2~Boston
1-2345~name3~Hungary
File1 is a variable length file where each column is seperated by delimitter "~".
File2:
ID Country
1-34<<11 SPACES>>USA<<7 spaces>>
1-234<<10 SPACES>>UK<<8... (5 Replies)
Hi, I have two files.
File1:
File1 contains two fixed width columns ID of 15 characters length and Name is of 100 characters length.
ID Name
1-43<<11 spaces>>Swapna<<94 spaces>>
1-234<<10 spaces>>Mani<<96 spaces>>
1-3456<<9 spaces>>Kapil<<95 spaces>>
File2:
... (4 Replies)
I am trying to parse a Fixed width file with data as below. I am trying to assign column values from each record to variables. When I parse the data, the spaces in all coumns are dropped. I would like to retain the spaces as part of the dat stored in the variables. Any help is appreciated.
I... (4 Replies)