Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Hi, I have a file sample_1.txt (300k rows) which has data like below: * Also each record is around 64k bytes
11|1|abc|102553|125589|64k bytes of data 10|2|def|123452|123356|...... 13|2|geh|144351|121123|... 25|4|fgh|165250|118890|.. 14|1|abc|186149|116657|...... 21|7|def|207048|114424|...... 23|7|geh|227947|112191|...... 26|32|fgh|248846|109958|...... 27|23|abc|269745|107725|...... 29|34|def|290644|105492|...... 30|32|geh|311543|103259|...... 33|23|fgh|332442|101026|...... 35|34|abc|353341|98793|...... 37|7|def|374240|96560|...... 39|4|geh|395139|94327|...... 41|2|fgh|416038|92094|...... 44|23|abc|436937|89861|...... 46|1|def|457836|87628|...... 48|3|geh|478735|85395|...... 50|23|fgh|499634|83162|......
I am trying to split the files based on the 2nd column like below sample_1_1.txt
11|1|abc|102553|125589|...... 14|1|abc|186149|116657|...... 46|1|def|457836|87628|......
sample_1_2.txt
10|2|def|123452|123356|...... 13|2|geh|144351|121123|...... 41|2|fgh|416038|92094|......
sample_1_3.txt
48|3|geh|478735|85395|......
and so on Could some help me on this. Thanks in advance

In reply to Split a file based on column 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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (4)
As of 2024-03-29 00:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found