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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |