Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
Hi , I have huge files around 400 mb, which has clob data and have diffeent scenarios: I am trying to pass scenario number as parameter and and get required modified file based on the scenario number and criteria. Scenario 1: file name : scenario_1.txt
1|1212|34353|56575|||||4|~somedata~some data~~~~~~~~~~~~some data~~~~~ +~~~~~~~~~some data~~~~~~~pi=[10.10.10.10.10],uid=[23231131]}~ 1|1212|34353|56575|||||4|~somedata~some data~~~~~~~~~~~~some data~~~~~ +~~~~~~~~~some data~~~~~~~pi=[10.10.10.10.11],uid=[3456]}~ 1|1212|34353|56575|||||4|~somedata~some data~~~~~~~~~~~~some data~~~~~ +~~~~~~~~~some data~~~~~~~pi=[10.10.10.10.12],uid=[659784]}~ 1|1212|34353|56575|||||4|~somedata~some data~~~~~~~~~~~~some data~~~~~ +~~~~~~~~~some data~~~~~~~pi=[10.10.10.10.13],uid=[654812]}~ 1|1212|34353|56575|||||4|~somedata~some data~~~~~~~~~~~~some data~~~~~ +~~~~~~~~~some data~~~~~~~pi=[10.10.10.10.14],uid=[323]}~ 1|1212|34353|56575|||||4|~somedata~some data~~~~~~~~~~~~some data~~~~~ +~~~~~~~~~some data~~~~~~~pi=[10.10.10.10.10],uid=[97945641564]}~ 1|1212|34353|56575|||||4|~somedata~some data~~~~~~~~~~~~some data~~~~~ +~~~~~~~~~some data~~~~~~~pi=[10.10.10.10.10],uid=[1654594]}~
Now I am trying to split the data like below to a new file scenario_1_n.txt: It should get all the data till last "|" and the pi, uid
1|1212|34353|56575|||||4|10.10.10.10.10|23231131 1|1212|34353|56575|||||4|10.10.10.10.11|3456 1|1212|34353|56575|||||4|10.10.10.10.12|659784 1|1212|34353|56575|||||4|10.10.10.10.13|654812 . . . .
Scenario 2: file name : scenario_2.txt
1|1212|34353|56575|||||4|~somedata~some data~~~~~~~~~~~~some data~~~~~ +~~~~~~~~~some data~~~~~~~390=10.10.10.10.10,391=23231131,394~ 1|1212|34353|56575|||||4|~somedata~some data~~~~~~~~~~~~some data~~~~~ +~~~~~~~~~some data~~~~~~~390=10.10.10.10.11,391=3456,394~ 1|1212|34353|56575|||||4|~somedata~some data~~~~~~~~~~~~some data~~~~~ +~~~~~~~~~some data~~~~~~~390=10.10.10.10.12,391=659784,394~ 1|1212|34353|56575|||||4|~somedata~some data~~~~~~~~~~~~some data~~~~~ +~~~~~~~~~some data~~~~~~~390=10.10.10.10.13,391=654812,394~ 1|1212|34353|56575|||||4|~somedata~some data~~~~~~~~~~~~some data~~~~~ +~~~~~~~~~some data~~~~~~~390=10.10.10.10.14,391=323,394~ 1|1212|34353|56575|||||4|~somedata~some data~~~~~~~~~~~~some data~~~~~ +~~~~~~~~~some data~~~~~~~390=10.10.10.10.10,391=97945641564,394~ 1|1212|34353|56575|||||4|~somedata~some data~~~~~~~~~~~~some data~~~~~ +~~~~~~~~~some data~~~~~~~390=10.10.10.10.10,391=1654594,394~
Now I am trying to split the data like below to a new file scenario_2_n.txt: It should get all the data till last "|" and the date after 390=, and 391=
1|1212|34353|56575|||||4|10.10.10.10.10|23231131 1|1212|34353|56575|||||4|10.10.10.10.11|3456 1|1212|34353|56575|||||4|10.10.10.10.12|659784 1|1212|34353|56575|||||4|10.10.10.10.13|654812 . . . .
Scenario 3: file name : scenario_3.txt
1|1212|34353|56575|||||4|~somedata~10.10.10.10.10~123546~~~~~~~~~~~som +e data~~~~~~~~~~~~~~some data~~~~~~~ 1|1212|34353|56575|||||4|~somedata~10.10.10.10.11~546~~~~~~~~~~~some d +ata~~~~~~~~~~~~~~some data~~~~~~~ 1|1212|34353|56575|||||4|~somedata~10.10.10.10.12~3415646~~~~~~~~~~~so +me data~~~~~~~~~~~~~~some data~~~~~~~ 1|1212|34353|56575|||||4|~somedata~10.10.10.10.13~12156~~~~~~~~~~~some + data~~~~~~~~~~~~~~some data~~~~~~~ 1|1212|34353|56575|||||4|~somedata~10.10.10.10.10~15464~~~~~~~~~~~some + data~~~~~~~~~~~~~~some data~~~~~~~ 1|1212|34353|56575|||||4|~somedata~10.10.10.10.10~8465~~~~~~~~~~~some +data~~~~~~~~~~~~~~some data~~~~~~~ 1|1212|34353|56575|||||4|~somedata~10.10.10.10.10~15654~~~~~~~~~~~some + data~~~~~~~~~~~~~~some data~~~~~~~
Now I am trying to split the data like below to a new file scenario_3_n.txt: It should get all the data till last "|" and the date after second~ and third~
1|1212|34353|56575|||||4|10.10.10.10.10|123546 1|1212|34353|56575|||||4|10.10.10.10.11|546 1|1212|34353|56575|||||4|10.10.10.10.12|3415646 1|1212|34353|56575|||||4|10.10.10.10.13|12156 . . . .
Thanks for looking and thanks for your help.

In reply to Split file using perl and regexp by brad_nov

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others imbibing at the Monastery: (13)
    As of 2015-07-07 16:01 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









      Results (91 votes), past polls