It's working! You're really great! I've been looking for scripts for a long time on how I can do it and it's working with the solution you've provided. Thanks so much! If it's not too much, can you please help me on how I modify the script that you provided to have the output like the one below? Thanks in advance!
expected output:
date time chdate chtime status calling cparty
20071009 12:45:36 20071009 12:45:43 201 644 xxxxxxx
20071010 03:09:13 20071010 03:10:07 29 644 xxxxxxx
Thanks for taking time to help me with my problem. I tried the solution that you've provided but the result is different. Can we just have one heading like the expected output below? Also if you can explain what the script does. Thanks a lot! I really appreciate all your help!
expected output:
date time chdate chtime status calling cparty
20071009 12:45:36 20071009 12:45:43 201 644 xxxxxxx
20071010 03:09:13 20071010 03:10:07 29 644 xxxxxxx
output of the script you've provided:
date time chdate chtime status calling cparty date time chdate chtime status calling cparty 20071009 12:45:36 20071009 12:45:43 201 644 xxxxxxx 20071010 03:09:13 20071010 03:10:07 29 644 xxxxxxx
For the sample that you provided it's working. But I use the actual input which is more than 5Mb of file. When I run using the script, it's output is different like what I mentioned in my previous post. I have attached a portion of the file since it's more than 5Mb I can't send it. Thanks again!
Also if you can explain what the script does. Thanks a lot!
Before explaining the script, it was written on the run - so its definitely not the optimized one
Code:
open(FILE, "<", "a");
open the file - as simple as the code explains
Code:
while(<FILE>) {
chomp;
my @arr = split(/></);
based on the delimiter '><' split the input record and populate in the array '@arr'
Code:
foreach (@arr) {
if( />/ && /</ ) {
iterate through the array and make sure processing proceeds only when both '>' and '<' are available. Because we are interested only in that data really
if its the first line, only then header has to be printed and not for consequent xml records. Block the input data by 'grouping' and mark the block as '\1' and '\2'
append the header and data individually to a variable
Thanks for the explanation for the scripts. I don't know why when I use the actual input file the output is not organized. What I wanted is to have one heading and then the values. when I tried the script, the headings are repeated several times and the values are under it. Please see details below. Hope you can help me organize the output.
expected output:
date time chdate chtime status calling cparty
20071009 12:45:36 20071009 12:45:43 201 644 xxxxxxx
20071010 03:09:13 20071010 03:10:07 29 644 xxxxxxx
output from scripts if the actual file is being used (more than 5MB file):
date time chdate chtime status calling cparty date time chdate chtime status calling cparty date time chdate chtime status calling cparty date time chdate chtime status calling cparty 20071009 12:45:36 20071009 12:45:43 201 644 xxxxxxx 20071010 03:09:13 20071010 03:10:07 29 644 xxxxxxx 20071010 03:09:13 20071010 03:10:07 29 644 xxxxxxx 20071009 12:45:36 20071009 12:45:43 201 644 xxxxxxx
Hi
I have xml file with multiple records and would like to extract records from xml with specific condition if specific tag is present extract entire row otherwise skip .
<logentry revision="21510">
<author>mantest</author>
<date>2015-02-27</date>
<QC_ID>334566</QC_ID>... (12 Replies)
Hi,
Can anybody help to solve this. I want to parse some xmldata along with the URL in the Shell.
I'm calling the URL via the curl command
Given below is my shell script file
export... (7 Replies)
In the wake of the post: how-parse-following-xml-file
Thank you for the very useful chakrapani response 302355585-post4 !
A close question.
How to pass a file to xmllint in variable?
For example, let it be:
NEARLY_FILE='<?xml version="1.0" encoding="iso-8859-1"?><html><set label="09/07/29"... (0 Replies)
Hi,
I have to make an script according to these:
- I have couples of files like:
xxxxxxxxxxxxx.csv
xxxxxxxxxxxxx_desc.xml
- every xml file has diferent fields, but keeps this format:
........
<defaultName>2011-02-25T16:43:43.582Z</defaultName>
........... (2 Replies)
Hi Everybody,
I have an XML file containing some data and i want to extract it, but the specific issue in my file is that the data is repeated some times like the following example :
<section1>
<subsection1>
X=...
Y=...
Z=...
<\subsection1>
<subsection2>
X=...
Y=...
Z=...... (2 Replies)
Hi All,
I have been working on something that doesn't seem to have a clear regex solution and I just wanted to run it by everyone to see if I could get some insight into the method of solving this problem.
I have a flat text file that contains billing records for users, however the records... (5 Replies)
Hi,
It's been a few years since college when I did stuff like this all the time. Can someone help me figure out how to best tackle this problem? I need to parse a file full of entries that look like this:
<eq action="A" sectyType="0" symbol="PGR" exch="CA" curr="VEF" sess="NORM"... (7 Replies)
Hi All,
My requirement is create an unix script to parse the xml file and display the values of the Elements/value between the tags on console. Like say, I would like to fetch the value of errorCode from the below xml which is 'U007' and display it. Can we use SED command for this? I have tried... (10 Replies)
Hello All,
I am new to this and I need to parse an XML file.
Here's the XML Input File:
<Report version="1.2">
<summary fatals="0" testcases="1" expected_fails="0" unexpected_passes="0" warnings="9" tests="21" errors="0" fails="1" passes="20" />
<testresult... (4 Replies)