I need help with this pseudo-code, I need to use PERL because another piece of a process uses it too.

## Pseudo code for counting iterations of 1 and 0 as listed on new lin +es in a .txt ##PREPARATION WORK** name input_file input_file = “C:\Video_Forensics\case_number_CV000001\frame3000-12 +034.txt” ## this is where the script should be modified to tailor to a specifi +c case or workstation Create file “iterations1.txt” ## this is the file that will be the new list counting the consecut +ive iterations of 1 create file “iterations0.txt” ## this is the file that will be the new list counting the consecut +ive iterations of 0 create object_1count object_1count=0 ## this will count the number of times that 1 has been read since the + last number was 0 create object_0count object_0count=0 ## this will count the number of times that 0 has been read since the + last number was 1 ##PREPARATION WORK** ##BODY** open read-only file input_file ## Open as read-only to avoid disturbing the integrity of the dat +a set ## This file should have only a 1 or a 0 written once on each lin +e and be a .txt file ## It should not be difficult to convert .csv or .xls to .txt read line number 1 of input_file If value=1, run loop1test. else if value=0, run loop0test. (loop1test) ## this loop initiates the logic chain when the data set starts with +a 1 and will be 0 when it changes set object_1count=( object_1count + 1) ## now the program is counting iterations of 1 run 1start_count_loop (end loop1test) (1start_count_loop) read next line If line value=1, set object_1count=( object_1count + 1) run 1start_count_loop ## The next line was still a 1, so continue counting else if line value=0 write object_1count to new line of file “iterations1.txt” then + save and close set object_1count=0 run loop0test else if line value = NULL (blank or there are no new lines) write object_1count to new line of file “iterations1.txt” +then save and close (end 1start_count_loop) (loop0test) set object_0count=( object_0count + 1) run 0start_count_loop (end loop0test) (0start_count_loop) read next line If line value=0, set object_0count=( object_0count + 1) run 0start_count_loop else if line value = 1 write object_0count to new line of file “iterations0.txt” then + save and close set object_0count=0 run loop1test else if line value = NULL (blank or there are no new lines) write object_0count to new line of file “iterations0.txt” +then save and close (end 0start_count_loop) close input_file ##BODY** end

Thanks for all your help


In reply to Counting iterations of 1 and 0 by AwsedreswA

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!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • 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, details, 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, summary, 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.