Hi forum members. It has been several years since my last post. Currently I am using fairly large datasets on a day to day basis for handling immigration cases at a law firm. Our Input file is filled out by our secretary staff. The first column is the case ID-sample ID then the second column is the sample ID, third is the relationship status and the fourth is the name.
What I need is a output file where the father (or mother) is compared to the child (daughter or son) so that the output file would be in rows with a specific syntax (please see the output file).
The file is tab seperated
Father and mother would be compared to all children (child, son and daughter)
If it is a son then a M would be used (e.g. ...[Jim Smith][M])
If it is a daughter then a F would be used (e.g.....[Jane Smith][F])
If the name is a child in the third column then it would be left blank (e.g..... [Randy Davis][])
Sometimes the list can have more than one child (e.g. up to 8 children) so then the father would have to be compared to all children in the output format.
Input file
Output file
Above is the output file. It would be best if the script is in perl however any code would help.
THanks
Last edited by kylle345; 09-20-2015 at 10:02 AM..
Reason: forgot to add more detail
You have shown us the output you want when the input has two parents and one child, and you have shown us the output you want when the input has one parent and more than one child. What output do you want when there are two parents and more than one child, such as with the input:
And, can there be a Father and/or a Mother with no Sons or Daughters? If so, what output do you want?
And, can there be a Son and/or a Daughter with no Mother or Father? If so, what output do you want?
Can there be anything other than Daughter, Father, Mother, and Son (e.g., Grand Daughter, Step Son, Brother, Aunt)?
This User Gave Thanks to Don Cragun For This Post:
No there is always a family with a child and either one or both parents.
There is always a father and/or mother + child in our cases.
When there are two parents and more then one child then the output would be:
Thanks
Quote:
Originally Posted by Don Cragun
You have shown us the output you want when the input has two parents and one child, and you have shown us the output you want when the input has one parent and more than one child. What output do you want when there are two parents and more than one child, such as with the input:
And, can there be a Father and/or a Mother with no Sons or Daughters? If so, what output do you want?
And, can there be a Son and/or a Daughter with no Mother or Father? If so, what output do you want?
Can there be anything other than Daughter, Father, Mother, and Son (e.g., Grand Daughter, Step Son, Brother, Aunt)?
---------- Post updated at 09:25 AM ---------- Previous update was at 09:18 AM ----------
Sorry I made the correction above with Ralph Davis.
M and F just stand for male and female in our cases.
Quote:
Originally Posted by RudiC
How come Jane Smith is an [F] - there's no daugther in that case. And why [Ralph Davis][F] - there's just one child?
Here is a slightly different approach to the problem using awk. Note that the sample input file in post #1 in this thread sometimes uses <tab>, sometimes uses <tab> and a few <space>s, and sometimes uses two or more <space>s as a field separator. (But a single <space> is not a field separator.)
The following code makes the assumption that parents are presented before their children:
If you change the limits on the for loops in the dump() function from:
to:
then the code will provide the desired output even if children appear in the input before, after, or in between their parents.
With the sample input currently shown in post #1 in this thread contained in file, the above code produces the output:
and, if file contains the sample input I asked about in post #2, it produces the output:
As always, if you want to try this on a Solaris/SunOS system, change awk to /usr/xpg4/bin/awk or nawk.
This User Gave Thanks to Don Cragun For This Post:
Hello, I need to get few values from a XML file and output needs to be written in another file with pipe delimited format. The Header & Footer of the Pipe Delimited file will be constant.
The below is my sample XML file. I need to pull the values in between the XML tags <Operator_info to... (15 Replies)
Hi ,
i am generating some data by firing sql query with connecting to the database by my solaris box.
The below one should be the header line of my excel ,here its coming in separate row.
TO_CHAR(C. CURR_EMP_NO
---------- ---------------
LST_NM... (6 Replies)
Hi,
I have a file with data in the following format
BOX
-1.000000 -1.000000 0.000000
30.00000 14.00000 0.1000000
0.000000 0.000000 0.000000
0.000000
0.000000
CYLINDER
3.595000 2.995000 0.000000
0.5100000 2.000000
Z
0.000000 0.000000
0.000000
I want to convert these files... (1 Reply)
Hi Folks,
I have few mailids in a text file and need to check whether the mailid is in correct format or not.
If just to check whether the string is a mailid or not there is a perl module Email::Valid to do the business or we can implement our own logic.
But the mail_ids I am having is... (4 Replies)
Hello,
I need help with a perl script that will process a text file and match virtual server name to profile(s). the rest will be ignored.
Virtual server name follows the word "virtual" in the begging of the line.
There could be multiple profiles assigned to one virtual server.
For example, ... (3 Replies)
Input_file_1:
ABC1 DEF11
ABC3 DEF7
ABC7 DEF36
Input_file_2:
DEF7 light 23
DEF11 over 2
DEF11 over 1
DEF17 blue 0
Perl one-liner that join two input file based on columns sharing a value (In this example, column 2 in Input_file_1 and column 1 in... (3 Replies)
Hi,
i need a perl script which reads the file, content is given below. and output in new file.
TARGET DRIVE IO1 IO2 IO3 IO4 IO5
------------ --------- --------- --------- --------- ---------
0a.1.8 266 236 ... (3 Replies)
Hi,
I am having couple of files which i used to copy from windows to Linux, so now in case of text files (CTRL^M) appears at end of line. I know i can convert this windows format file to unix format file by running dos2unix.
My requirement here is that i want to do it automatically using a... (5 Replies)
Hi everyone, is there any way in perl using which we can print the selective words in bold when we write the output to a csv file?
Please find the example below
1. Filename: A
2. name age 12
3. city add 23
Line1 should only be bold. Outputs from other files being read in the... (2 Replies)
Hi,
I have written a perl script to dispaly some statements from a file but i want the output statements to be dispalyed in an HTML format.Is it possible for me to do in perl scripting?
Please help me with ur thoughts.
Thanks In Advance
Meva. (1 Reply)