XML file to be split into 3 XML files

Phie -  
lami20j Posted messages 21506 Registration date   Status Moderator, Security Contributor Last intervention   -
Hello,
I want to split a xml file into three xml files of roughly equal size.

I tried the function csplit -f fic_ test.xml '/<riskAggregatedMessage>/' '{*}' and I have two problems:
1) this function gives me one file per record instead of correctly splitting into 3 files with respect to the tags... this forces me to concatenate the files afterwards... if I could avoid that, it would be great!

2) the option '{*}' does not work. I get the following error message: "csplit: Illegal repeat count: {*}"
Why?

Thanks in advance!
phie
Configuration: Windows XP Firefox 2.0.0.11

3 answers

  1. lami20j Posted messages 21506 Registration date   Status Moderator, Security Contributor Last intervention   3 571
     
    Hi,

    http://www.commentcamarche.net/faq/sujet 953 linux splitting a file into multiple parts

    --
    106485010510997108
    0
    1. Phie
       
      Hello,
      I had indeed seen this option, but the problem is that the file I want to split is an XML file, so I cannot split it based on size or number of lines: I could have an open tag in the first file and a closed one in the second...
      0
  2. lami20j Posted messages 21506 Registration date   Status Moderator, Security Contributor Last intervention   3 571
     
    Re,

    You can then calculate the number of characters and then with a script divide it into 3, taking as conditions the division by three as well as the position of the opening/closing tag at the beginning and end of each part
    --
    106485010510997108
    0
    1. Phie
       
      and how do we do that?
      0
  3. lami20j Posted messages 21506 Registration date   Status Moderator, Security Contributor Last intervention   3 571
     
    Hi,

    put your file on cjoint.com and I'll check it out tonight
    --
    106485010510997108
    0