Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^3: Merging two files and changing format

by choroba (Bishop)
on Oct 12, 2012 at 07:29 UTC ( #998622=note: print w/replies, xml ) Need Help??


in reply to Re^2: Merging two files and changing format
in thread Merging two files and changing format

Please, show an example of a pair of lines that is not processed correctly.
لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
  • Comment on Re^3: Merging two files and changing format

Replies are listed 'Best First'.
Re^4: Merging two files and changing format
by webby01 (Initiate) on Oct 12, 2012 at 16:46 UTC

    your code is printing extra blank lines between lines of good output

    sed -n '1, 5{=;p;}' test2

    1

    M MitoA10045G 0 10045 A A A A...

    2

    3

    M MitoA10551G 0 10551 A A A A ...

    4

    5

    M MitoA11252G 0 11252 A A A A ...

      This does not happen when I test it. Please, provide a sample of the input files in <code> ... </code> tags.
      لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
        M MitoA10045G 0 10045 M MitoA10551G 0 10551 M MitoA11252G 0 11252 M MitoA11468G 0 11468 M MitoA11813G 0 11813 M MitoA12309G 0 12309 M MitoA13106G 0 13106

        Each line of the following file corresponds with each line of the previous file

        AA AA AA AA AA AA ... AA AA AA AA AA AA ... AA AA AA AA AA AA ... AA AA AA AA AA AA ... AA AA AA AA AA AA ... AA AA AA AA AA AA... AA AA AA AA AA AA...

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://998622]
help
Chatterbox?
[ovedpo15]: consider the following format of strings: some_data-doesn't- matter,value. how I get the value with regex? it should be after the last comma (last string)
[Corion]: Text::CSV_XS for all your CSV file parsing needs. Other than that, what problems do you have with perlre, and capturing everything after the comma? Also, index and substr would also work.
[choroba]: my ($value) = $string =~ /.*,(.*)/
[choroba]: The .* at the beginning matches the longest possible substring, so it eats any previous commas
[choroba]: But for CSV, use appropriate modules

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (6)
As of 2018-05-27 08:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?