This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I have a xml file in which there is data from multiple tables. The file looks like -- test.xml
I want to make two file from this Activities.xml and second Contact.xml
Activities.xml will have
And Contact.xml will have
The number of rows in each table will vary. Also there are more than two tables , so tags like Activity and Contact can be many, each one having many rows. I need to create sepearte file for each of these main tags.
Is it possible to do it using shell script? Or should I be using something else?
Please help Thanks!
[ EJFH: Fixed up code samples. ] [ September 27, 2004: Message edited by: Ernest Friedman-Hill ]
These files don't look like xml at all. Are you sure, that that's the real content of the files, and not only the rendered output of some tool?
If the format is allways
(int) (date) X
a script, reading the file and evaluating regex should work. Do you use bash?
I guess awk is the best tool to do the work, but I'm not well in awk. Here is a sed-solution, which will eliminate the blanks:
Note that I inserted 3 CRs into the statements, which shall avoid an endless line here in the forum, which you have to remove for the script to work. And for the time, the pattern could be made more restrictive. [ September 27, 2004: Message edited by: Stefan Wagner ]
Here are further details. The file that I have is a huge file with data from many tables. Basically I have to load this xml file into Oracle tables. I have written Oracle Pl sql procedure using XML_Save pacakge to achive loading of data given, file name (file should have data only from one table), and table name to which the data should be loaded.
Now the problem I am facing is, the file that our system will receive will have data from all the tables together. Not that I will get seperate file for each table. Henc I thought of breaking the files into various files such that each file will have data from only one table.
I tried to do it using Unix shell scripts. But have not been successful yet. Reason being -- The file that our system is receiving will all this data in single line (with no newline character at all) (Isn't it crazy???) Also the file size is around 5MB.
Any suggestions as to what should I use to break this file. The contets of the files will vary (Sometime Activity table will not have any data in it to no rows with <Activities> tag will be there. Hence if I understand correctly both he solutions suggested above are not able to handle this dynamic nature of the file.
I have tried using sed in Unix but it did not work due to I guess file size and basically this dumb file having no newline characters in it.
[ October 01, 2004: Message edited by: Gemini Moses ] [ October 01, 2004: Message edited by: Gemini Moses ]