Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^8: Bit handling in Perl

by vaidhy_m (Novice)
on Oct 26, 2014 at 04:35 UTC ( [id://1105015]=note: print w/replies, xml ) Need Help??


in reply to Re^7: Bit handling in Perl
in thread Bit handling in Perl

I might consider moving my Turboencabulator to the kitchen, thanks for the suggestion! On the other hand, this is the script I used to convert the csv file to binary, which works flawlessly for most rows in my csv file.

open(A,"6k6.csv"); open(B,">6k6.fp"); binmode B; while(<A>) { if($_=~m/(".*"),(.*)/gi) { $temp=$2; $temp=~tr[,\n][]d; print B "$1".pack 'b*',$temp; print B "\n"; } }

Then I used vec to write out each bit from the bit string on a separate file which showed me some lines are not converted as it is into binary.

Replies are listed 'Best First'.
Re^9: Bit handling in Perl
by BrowserUk (Patriarch) on Oct 26, 2014 at 14:06 UTC

    In order that we might reproduce your problem, we need:

    1. The exact code you are using:

      I'm hoping what you've posted, devoid of strict & warnings and any attempt at error checking, is not the actual code you are using?

      If it is; get your act together and make some attempt to solve your own problems before coming here for help!

    2. A sample input that produces the problem:

      Take this from your real file, but only post a couple of records that do work and one or two that don't. (Don't forget to use <code></code> tags.)

    3. The output produced by your real code when run against the sample input.

      Again, don't forget the code tags.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

      1. The code that I wrote is as follows.

      #! usr/bin/perl #convert csv to binary use strict; use warnings; open(A,"k.csv") or die "File not found\n"; open(B,">m.fp"); binmode B; while(<A>) { if($_=~m/(".*"),(.*)/gi) { my $temp=$2; $temp=~tr[,\n][]d; print B "$1,".pack 'b*',$temp; print B "\n"; } } close(A); close(B); open(C,"m.fp") or die "File not found\n"; open(D,">>k.csv"); binmode C; print D "\n"; while(<C>) { if($_=~m/(".*"),(.*)\n/gi) { print D "$1,"; my $a=$2; my $i; for($i=0;$i<=880;$i++) { print D vec($a,$i,1).","; } print D "\n"; } } close(C); close(D);

      2. The test data where first two rows are properly converted to binary and the next two are not.

      "Test1",1,1,1,0,0,0,0,0,0,1,1,1,1,0,1,1,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,1,0,0,0,1,0,0,1,0,0,0,0,0,0,1,0,0,0,0 +,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,1 +,0,0,1,1,1,0,0,0,0,1,1,0,0,1,1,1,1,0,0,0,0,0,0,1,1,0,0,0,1,1,1,1,1,0, +1,1,0,0,0,1,1,0,1,1,1,1,0,0,1,1,1,1,0,0,1,0,0,0,0,0,0,1,0,1,0,0,0,1,0 +,0,0,0,0,0,1,0,1,0,1,0,0,0,0,0,0,0,0,0,1,1,1,0,1,1,0,1,0,1,0,1,1,1,0, +1,1,1,0,1,0,1,0,1,0,0,0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0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,

      I then compared each input row to its output counterpart along each column using Excel formula and found that the last two output rows [row 8,9] are different from their input rows [row 3,4].

        Your problem is that you are mixing binary and text operations on the same file.

        When you are writing your records out, you are adding a "\n" at the end, and when you are reading them back you are relying upon readline to read back the appropriate number of characters by reading until it sees this newline.

        The problem comes when one of your binary records contains a data byte that happens to look like an LF character (0x0a; decimal 10).

        So, for example, in the third record of your sample, the 56th set of 8 1s&0s looks like this: 0,1,0,1,0,0,0,0, which when packed using the 'b*' template, gets translated in a byte value of 0x0a.

        Then, when you read the binary record back using readline (aka. <C>), perl sees that byte value as the end of the record, hence everything after that is wrong.

        The answer is (as hinted at in my first reply to you above) is to not use text operations (newline record separators and readline) on your binary files.

        Instead, when reading your binary files, you should use read and the exact number of bytes to read each record.

        Study the documentation for read.


        With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1105015]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2024-04-24 02:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found