Comparing and Formatting the text file
hi,
I need a script which can format the below text file which contains comments Code: Code:
Output should be: Code: Code:
Name |Date|Function Name|Changes I am trying this, can anybody please help me on this. |
Happy to help ... what have you got so far? Are you using a particular app/script/language?
|
Yes, Linux script.
I got the follwoing script. But the below script works only for 3 columns. I need to do it for 4 columns given in the above sample file. Quote:
Quote:
Now, am trying to apply to four feild, it is not working. I need this urgently and it is not working. Please help me. |
So I am not understanding, you want the words Date, Name, etc or you want the field that they refer too or are the words you have written actually what they say they are? ie Date is an actual date?
If you sample is: Code:
START |
hi Grail,
The above code given by me, would work for yor sample file. Suppose if the function name exceeds more than 2 lines, then the code is not working propoerly. I need code for this sample file: Quote:
|
For easily extracting the value of function name and Changes, if needed i can place delimeters for the sub-headings (like fucntion name, changes) start and end as follows.
Quote:
Since am new to awk programming i am not aware of how to traverse in a given feild. |
See what ya think:
Code:
#!/usr/bin/awk -f |
hi Grail,
The code is not working. I have saved the code given by you in a file awk-script and removed the first statement since it was throwing error. The sample file is saved in file.txt Executed the below way: Quote:
But the output is : Quote:
Quote:
|
So you will need to do the formatting part, but as you can see the data in both is mostly equivalent. It is only the part enclosed by:
END{} That you need to look at for formatting. |
hi Grail,
I need to understand the logic written so that i can format it accordingly. Can you please explain me. |
hi Grail,
I got an idea, instead of writing an AWK script for formatting, can we merge the lines in changes and function name so that we can use the awk script given by me above to do the formatting. Suppose, I have a file as below: Code: Quote:
Code: Quote:
|
So using your input from post #5 and with the small changes made to script as below, see output:
Code:
#!/usr/bin/awk -f Code:
./script.awk input_file Code:
Name|Date|Function Name|Changes Post back on anything that you get stuck on |
Thanks Grail. It is working perfectly. :)
I have done debug of each and every line and got the logic. I dont think the following code is required. As per my understanding this is placed to have an array of val in an array- array_vals. Removal of this, the code works fine. Please correct me if am wrong. Quote:
|
Yeah that was for older stuff and can be removed.
|
All times are GMT -5. The time now is 02:06 AM. |