06-27-2011
Apply condition on fixed width file and filter records
Dear members..
I am further refining my requirement as below:-
I have a fixed width file. Requirement is as below:-
1. Scan each record from this fixed width file
2. Check for value under field no "6" equals to "6". If yes, then filter this record into the output file
Please suggest a unix command to achieve this, my guess awk might work here
Illustration below:-
----------------
Suppose source file has 3 records as below
123456789 => As per requirement, this record should flow into output
123459789 => This records should NOT go to ouput
123455789 => This records should NOT go to ouput
658986215 => As per requirement, this record should flow into output
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
I am using the following command at the Unix prompt to make my 'infile' into a fixed width file of 100 characters.
awk '{printf "%-100s\n",$0}' infile > outfile
However, there are some records with a special character "©"
These records are using 3 characters in place of one and my record... (2 Replies)
Discussion started by: alok.benjwal
2 Replies
2. Shell Programming and Scripting
Greetings,
I would like to extract records from a fixed width text file that have unique field elements.
Data is structured like this:
John A Smith NY
Mary C Jones WA
Adam J Clark PA
Mary Jones WA
Fieldname / start-end position
Firstname 1-10... (8 Replies)
Discussion started by: sitney
8 Replies
3. UNIX Desktop Questions & Answers
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)
Discussion started by: sate911
4 Replies
4. Shell Programming and Scripting
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)
Discussion started by: Amit.Sagpariya
5 Replies
5. Shell Programming and Scripting
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)
Discussion started by: Muga801
4 Replies
6. Shell Programming and Scripting
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)
Discussion started by: anshul_er
10 Replies
7. UNIX for Dummies Questions & Answers
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.
awk '{print length;exit}' <File_name>
The above code gives me length 50.
wc -L <File_name>
The above code gives me length 53.
Please clarify on... (2 Replies)
Discussion started by: Amrutha24
2 Replies
8. Shell Programming and Scripting
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)
Discussion started by: vinus
6 Replies
9. Shell Programming and Scripting
Hi All,
I am trying to select the rows in a fixed width file based on values in the columns.
I want to select only the rows if column position 3-4 has the value AB
I am using cut command to get the column values. Is it possible to check if cut -c3-4 = AB is true then select only that... (2 Replies)
Discussion started by: ashok.k
2 Replies
10. Shell Programming and Scripting
I have csv file with 30, 40 columns
Pasting just three column for problem description
I want to filter record if column 1 matches CN or DN then,
check for values in column 2 if column contain 1235, 1235 then in column 3 values must be sequence of 2345, 2345
and if column 2 contains 6789, 6789... (5 Replies)
Discussion started by: as7951
5 Replies
LEARN ABOUT DEBIAN
px_get_record2
PX_GET_RECORD2(3) Library Functions Manual PX_GET_RECORD2(3)
NAME
PX_get_record2 -- Returns record in Paradox file
SYNOPSIS
#include <paradox.h>
int PX_get_record2(pxdoc_t *pxdoc, int recno, char *data, int *deleted, pxdatablockinfo_t *pxdbinfo)
DESCRIPTION
This function is similar to PX_get_record(3) but takes two extra parameters. If *deleted is set to 1 the function will consider any record
in the database, even those which are deleted. If *pxdbinfo is not NULL, the function will return some information about the data block
where the record has been read from. You will have to allocate memory for pxdbinfo before calling PX_get_record2.
On return *deleted will be set to 1 if the requested record is deleted or 0 if it is not deleted. The struct pxdatablockinfo_t has the fol-
lowing fields:
blockpos (long)
File positon where the block starts. The first six bytes of the block contain the header, followed by the record data.
recordpos (long)
File position where the requested record starts.
size (int)
Size of the data block without the six bytes for the header.
recno (int)
Record number within the data block. The first record in the block has number 0.
numrecords (int)
The number of records in this block.
number (int)
The number of the data block.
This function may return records with invalid data, because records are not explizitly marked as deleted, but rather the size of a valid
data block is modified. A data block is a fixed size area in the file which holds a certain number of records. If for some reason a data
block has newer been completely filled with records, the algorithmn anticipates deleted records in this data block, which are not there.
This often happens with the last data block in a file, which is likely to not being fully filled with records.
If you accessing several records, do it in ascending order, because this is the most efficient way.
Note:
This function is deprecated. Use PX_retrieve_record(3) instead
RETURN VALUE
Returns 0 on success and -1 on failure.
SEE ALSO
PX_get_field(3), PX_get_record(3)
AUTHOR
This manual page was written by Uwe Steinmann uwe@steinmann.cx.
PX_GET_RECORD2(3)