delete a column in XML file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting delete a column in XML file
# 1  
Old 10-26-2011
delete a column in XML file

I have any XML ouput file(file name TABLE.xml), where the data is loaded in A SINGLE LINE, I need need help in writting a ksh shell script which gives me the output which should not have column S_NO

This is my input file which has S_NO column.

<?xml version="1.0" encoding="UTF-8"?><!--Generated by Ascential Software Corporation, DataStage - XMLOutput stage - Tue Oct 25 11:22:28 2011 --><TABLE><TABLE-ROW><S_NO>1</S_NO><REP_TYPE>TEST1</REP_TYPE><PROCESS_OFFICE>P</PROCESS_OFFICE><PACKAGE_LEVEL>C</PACKAGE_LEVEL></TABLE-ROW><TABLE-ROW><S_NO>2</S_NO><REP_TYPE>TEST2</REP_TYPE><PROCESS_OFFICE>L</PROCESS_OFFICE><PACKAGE_LEVEL>C</PACKAGE_LEVEL></TABLE-ROW><TABLE-ROW><S_NO>3</S_NO><REP_TYPE>TEST3</REP_TYPE><PROCESS_OFFICE>L</PROCESS_OFFICE><PACKAGE_LEVEL>C</PACKAGE_LEVEL></TABLE-ROW></TABLE>

Expected output for the above xml file

<?xml version="1.0" encoding="UTF-8"?><!--Generated by Ascential Software Corporation, DataStage - XMLOutput stage - Tue Oct 25 11:22:28 2011 --><TABLE><TABLE-ROW><REP_TYPE>TEST1</REP_TYPE><PROCESS_OFFICE>P</PROCESS_OFFICE><PACKAGE_LEVEL>C</PACKAGE_LEVEL></TABLE-ROW><TABLE-ROW><REP_TYPE>TEST2</REP_TYPE><PROCESS_OFFICE>L</PROCESS_OFFICE><PACKAGE_LEVEL>C</PACKAGE_LEVEL></TABLE-ROW><TABLE-ROW><REP_TYPE>TEST3</REP_TYPE><PROCESS_OFFICE>L</PROCESS_OFFICE><PACKAGE_LEVEL>C</PACKAGE_LEVEL></TABLE-ROW></TABLE>

I need to run this script to an XML file (single line file) which has 2 Million rows.

Last edited by pred55; 10-26-2011 at 02:12 AM..
# 2  
Old 10-26-2011
Tryt his...
Code:
sed 's!<S_NO>[0-9]*</S_NO>!!g' input_file

--ahamed
This User Gave Thanks to ahamed101 For This Post:
# 3  
Old 10-26-2011
Ahamed, your script is working fine, but the only problem is that, this script just print out the data without <S_NO>-----</S_NO>, I want the output to be saved in another file.
# 4  
Old 10-26-2011
Code:
sed 's!<S_NO>[0-9]*</S_NO>!!g' input_file > output_file

--ahamed
This User Gave Thanks to ahamed101 For This Post:
# 5  
Old 10-26-2011
ahamed, thank you very much for your fast response.
It worked well.. thanks
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to delete 'duplicated' column values and make a delimited file too?

Hi, I have the following output from an Oracle SQL statement and I want to remove duplicated column values. I know it is possible using Oracle analytical/statistical functions but unfortunately I don't know how to use any of those. So now, I've gone to PLAN B using awk/sed maybe or any... (5 Replies)
Discussion started by: newbie_01
5 Replies

2. Shell Programming and Scripting

Overwrite specific column in xml file with the specific column from adjacent line

I have an xml file dumped from rrd file, that I want to "patch" so the xml file doesn't contain any blank hole in the resulting graph of the rrd file. Here is the file. <!-- 2015-10-12 14:00:00 WIB / 1444633200 --> <row><v> 4.0419731265e+07 </v><v> 4.5045912770e+06... (2 Replies)
Discussion started by: rk4k
2 Replies

3. Shell Programming and Scripting

Delete Description column from a csv file

Hi Friends, I have a scenario where in I need to implement the following logics. 1. Delete a column named "DESCRIPTION'" from a csv file(sample.csv). 2. Move "CURRENT_SALES" column to 10th position in columns from the same file. Thanks in Advance, Pons (10 Replies)
Discussion started by: ponnst
10 Replies

4. Shell Programming and Scripting

Delete an entire column from a tab delimited file

Hi, Can anyone please tell me about how we can delete an entire column from a tab delimited file? Mu input_file.txt looks like this: And I want the output as: I used the below code nawk -v d="1" 'BEGIN{FS=OFS="\t"}{$d=""}{print}' input_file.txtBut in the output, the first column is... (5 Replies)
Discussion started by: sampoorna
5 Replies

5. Shell Programming and Scripting

Read column from file and delete rows with some condition..

Hi.... I have a need of script to do delete row whenever condition is true.... 2.16 (3) 1 3 9999 0 (1) (0) 34.42 (4) 1 3 9999 37 (2) (3) 34.38 (4) 1 3 9999 64 (2) (3) 34.4 (4) 1 3 1 ... (13 Replies)
Discussion started by: nex_asp
13 Replies

6. UNIX for Dummies Questions & Answers

Delete a record in a xml file using shell scripting

find pattern, delete line with pattern and 3 lines above and 8 lines below the pattern. The pattern is "isup". The entire record with starting tag <record> and ending tag </record> containing the pattern is to be deleted and the rest to be retained. <record> ... (4 Replies)
Discussion started by: sdesstp
4 Replies

7. Shell Programming and Scripting

convert huge .xml file in .csv with specific column.

I have huge xml file in server and i want to convert it to .csv with specific column ... i have search in blog but i didn't get any usefully command. Thanks in advance (1 Reply)
Discussion started by: pareshkp
1 Replies

8. Shell Programming and Scripting

Search a file column wise and delete it

Scottn, m really sorry but i have not got my answer yet. my concern is how to delete the row !!! i have a file which has a column that is unique i am intending to serach it and if it is there to remove the row. the file looks like ROLLNO,NAME ,SUB1,SUB2,SUB3,TOTAL,PERCENTAGE,RESULT... (9 Replies)
Discussion started by: gotam
9 Replies

9. Shell Programming and Scripting

Search a file column wise and delete it

i have a file which has a column that is unique i am intending to serach it and if it is there to remove the row. the file looks like ROLLNO,NAME ,SUB1,SUB2,SUB3,TOTAL,PERCENTAGE,RESULT 15 ,rig ,34 ,56 ,87 ,177 ,59 % ,PASS 23 ,wel ,45 ,76 ,56 ,177 ,59 % ... (0 Replies)
Discussion started by: gotam
0 Replies

10. Shell Programming and Scripting

Delete first column in tab-delimited text-file

I have a large text-file with tab-delimited genetic data that looks like: KSC112 KSC234 0 0 1 1 A G C T I simply wan to delete the first column, but since the file has 600 000 columns, it is not possible with awk (seems to be limited at 32k columns). Does anyone have an idea how to do this? (2 Replies)
Discussion started by: andmal
2 Replies
Login or Register to Ask a Question