Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need python help .. I need to know if a user were to input 3 commands to a program and run it such as

I need python help .. I need to know if a user were to input 3 commands to a program and run it such as specify: Usage: ./filemaker INPUTCOMMANDFILE OUTPUTFILE RECORDCOUNT (./filemaker is the program)( (INPUTCOOMANDFUILE= a text file that contains key words that need to be searched through then decided what to do ) (RECORDCOUNT= number)

This is what I need to do: Given an input file that contains the following:

for example: Scenario: Script outputs the correct number of records Given a file named "smallcmd" with: """ STRING "hello, world! " """ When I run `../bin/filemaker smallcmd smalloutput 3` Then the file "smalloutput" should contain: """ hello, world! hello, world! hello, world! """

What i need is for the python program to be able to search the text file, and put it either in a list or a dictionary or both.. It needs to search that file for the if the KEYWORD "STRING" is in that file.. if it is it then needs to match the output that i have shown print only the letters or string that comes after that keyword.. in this case since the user entered the number 3 it has to loop that 3 times.. exactly as the input shows.. please make sure that the output is sent to a textfile

I need python help .. I need to know if a user were to input 3 commands to a program and run it such as specify: Usage: ./filemaker INPUTCOMMANDFILE OUTPUTFILE RECORDCOUNT (./filemaker is the program)( (INPUTCOOMANDFUILE= a text file that contains key words that need to be searched through then decided what to do ) (RECORDCOUNT= number)

This is what I need to do: Given an input file that contains the following:

for example: Scenario: Script outputs the correct number of records Given a file named "smallcmd" with: """ STRING "hello, world! " """ When I run `../bin/filemaker smallcmd smalloutput 3` Then the file "smalloutput" should contain: """ hello, world! hello, world! hello, world! """

What i need is for the python program to be able to search the text file, and put it either in a list or a dictionary or both.. It needs to search that file for the if the KEYWORD "STRING" is in that file.. if it is it then needs to match the output that i have shown print only the letters or string that comes after that keyword.. in this case since the user entered the number 3 it has to loop that 3 times.. exactly as the input shows.. please make sure that the output is sent to a textfile Thanks please ask me to clarify anything

Please read all of the insutrctions . I will do my best to explain what is needed. Must be written in python.

-Objective: read a le of commands and output a number of records that matches those commands. In a sense, you are writng a simple command interpreter.

Usage: ./lemaker ( this is what the user will enter, a file that will containt a text document, then they will have an outputfile and a number that will be used for determing what to do with the output.

- The program needs to be able to search the text file and find a key word and then process that information depending on that key ( Correct Number of records, HEADER command, STRING command,FILEWORD command)

Here are the files that will be passed in by the user and then the output file must match

for example: Scenario: Script outputs the correct number of records Given a file named "smallcmd" with: """ STRING "hello, world! " """ When I run `../bin/filemaker smallcmd smalloutput 3` Then the file "smalloutput" should contain: """ hello, world! hello, world! hello, world! """

or

Scenario: Script supports the HEADER command Given a file named "headercmd" with: """ HEADER "This is a header with an imbedded tab character " STRING "just a string " """ When I run `../bin/filemaker headercmd headeroutput 2` Then the file "headeroutput" should contain: """ This is a header with an imbedded tab character just a string just a string """ or Scenario: Script supports the STRING command Given a file named "anotherstringcmd" with: """ STRING "yet another string " """ When I run `../bin/filemaker anotherstringcmd anotherstringoutput 3` Then the file "anotherstringoutput" should contain: """ yet another string """

or Scenario: Script supports the FILEWORD command Given a file named "filewordcmd" with: """ FILEWORD filelabel "words" """ Given a file named "words" with: """ one two three four five """ When I run `../bin/filemaker filewordcmd filewordoutput 1` Then the file "filewordoutput" should match /one|two|three|four|five/

or

Scenario: Script supports the NUMBER command Given a file named "numbercmd" with: """ NUMBER numlabel 1 1999 STRING " " """ When I run `../bin/filemaker numbercmd numberoutput 3` Then the file "numberoutput" should match /^\d+ \d+ \d+ /

or Scenario: Script supports the REFER command to a label on a FILEWORD command Given a file named "morewords" with: """ this is a test """ Given a file named "referfilewordcmd" with: """ FILEWORD flabel "morewords" STRING " and " REFER flabel STRING " and " REFER flabel """ When I run `../bin/filemaker referfilewordcmd referfilewordoutput 1` Then the file "referfilewordoutput" should match /^(\w+) and \1 and \1$/ expected "\"\" morewords \"\"\" " to match /^(\w+) and \1 and \1$/ or

Scenario: Script supports the REFER command to a label on a NUMBER command Given a file named "refernumbercmd" with: """ NUMBER numlabel 1 99999 STRING " I said " REFER numlabel STRING " I said " REFER numlabel """ When I run `../bin/filemaker refernumbercmd refernumberoutput 1` Then the file "refernumberoutput" should match /^(\d+) I said \1 I said \1$/ expected "\"\" \"\"\" " to match /^(\d+) I said \1 I said \1$/

image text in transcribed

image text in transcribed

Files Module 6.pdf odf ule 6.pdf (117 KB) How is This Done in Python? Verify the commandline parameters Open the two files using try/except to trap and report errors Read all of the commands into a commands list using shlex Don't just slurp them, read them individually and save them in a list (I called my commands list "commands") Immediately output the string on the HEADER command (s) when you read them. Then discard the HEADER commands, you won't need them again Append the STRING, REFER and NUMBER commands as you read them at the end of the commands list. For FILEWORD, open and slurp the entire file into a dictionary (I called mine "random Files" with key the name of the file and the value is the entire file, slurped in as a list. Then append the FILEWORD command at the end of the commands list. 20 Files Module 6.pdf odf ule 6.pdf (117 KB) How is This Done in Python? Verify the commandline parameters Open the two files using try/except to trap and report errors Read all of the commands into a commands list using shlex Don't just slurp them, read them individually and save them in a list (I called my commands list "commands") Immediately output the string on the HEADER command (s) when you read them. Then discard the HEADER commands, you won't need them again Append the STRING, REFER and NUMBER commands as you read them at the end of the commands list. For FILEWORD, open and slurp the entire file into a dictionary (I called mine "random Files" with key the name of the file and the value is the entire file, slurped in as a list. Then append the FILEWORD command at the end of the commands list. 20

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Graph Database Modeling With Neo4j

Authors: Ajit Singh

2nd Edition

B0BDWT2XLR, 979-8351798783

More Books

Students also viewed these Databases questions

Question

What are the qualities to look for in a prospective franchisee?

Answered: 1 week ago

Question

How do Excel Pivot Tables handle data from non OLAP databases?

Answered: 1 week ago