Menu

(Solved) : Challenge Read Text File Capture Timestamp Form Line Text Create File List Timestamps Occu Q37174038 . . .

In this challenge, read a text file and capture a timestamp formeach line of text. Then create a file with a list of all timestampsthat occur multiple times, each…In this challenge, read a text file and capture a timestamp from each line of text. Then create a text file with a list of alSample Input hosts_access log 08.txt Sample Output Given Mename = hosts access og 00.txt. process the records in nosts acce

Python 3

In this challenge, read a text file and capture a timestamp from each line of text. Then create a text file with a list of all timestamps that occur multiple times, each on its own line. Naming convention and a data description are as follows: Naming convention: You will be provided with an input file name called ename. Your output filename should be req filename aplace filename). Data description: Each line of the .txt file contains a single lag record for July 1995 with the following columns in order: 1. The hastname of the host making the request. 2. This columns values are missing and descnbed by a hyphen (Le..J. 3. This column’s values are missing and descnbed by a hyphen fi.e., 4. A timestamp enclosed in square brackets following the format DDimmmYYYYHHMM SS-0400j, where DD is the day of the month, mmm is the name of the month, YYYY is the year, HH:MM SS is the time in 24-hour format, and -0400 is the tirne zone. 5. The request, enclosed in quotes (e.g., ‘GET Simages/NASA-logosmali.git HTTP T.0) 6. The HITP resporise code 7. The total number of bytes sent in the response. For example, given the following log record: to1/3u1/1995:8:00:12 -081 “GET /shuttle/countdown/viden/1ivevideo.gif HTTP/1.o” 280 burger.letters.com – – [ We can label each columin in the record like so: Request Bytes HTTP Rcponse Code 3Jul 1995:CC::2-0400 200 burger.lectes.com Given a string, ilenarrne, that denotes the name of a rual text file, create an output file named req filename to store timestamp records. Each line of the output file must contain a timestamp in the forrnat DD Y yY:HHIM SS for any timestamp that appears in more than one request in filename. The line order in the output file does not matter. Constraints The log file contains no more than 2x 105 records. Sample Input hosts_access log 08.txt Sample Output Given Mename = “hosts access og 00.txt”. process the records in nosts access g 00. txt and create an output file named req hosts access 09-00 txt c the following rows: 81/Ju1/1995:08:80:12 81ul/1995:0B:00:14 ล1/Jul /1995 : 08:00:15 Explanation 0 The lag file hasts_access lag 00.txt contains the following log records: unicomp6.unicomp.net –[81/Jul/1995:00:00:06 -0408] “GET /shuttle/countdown/ HTTP/1.8″288 3985 burger.letters.com [01/3ul/1995:80:00:11 0480] “GET /shuttle/countdown/Liftoff.html HTTP/1.8″304 8 burger.letters.com[01/3uL/1995:80:00:12 0480] “GET/images/NASA-logosmall.gif HTTP/1.8” 3848 burger.letters.com [01/3uL/1995:00:00:12 0480] “GET shuttle/countdown/video/livevideo.gif HTTP/1.8″ 208 0 d104.aa.net — [01Jul/1995:00:00:13 -040″GET/shuttle/countdown/ HTTP/1.0” 200 3985 unicomp6.unicomp.net – – [01/Jul/1995:80:00:14 -848 “GET /shuttle/countdown/count.gif HTTP/1.” 208 48310 unicomp6.unicomp.net – – [01/Jul/1995:80:00:14 -8481 “GET images/NASA-logosmall.gif HTTP/1.8” 200 786 unicomp6.unicomp.net – – [01/Jul/1995:80:00:14 -8481 “GET /images/KSC-logol.gif HTTP/1.” 280 1284 d104.aa.net – ø1/Jul/1995:08:08:15 -0401 “GET /shuttle/countdown/count.gif HTTP/1.8” 288 40310 d104.aa.net – [01/Jul/1995:08:08:15 -0400] “GET /images/NASA-logosmall.gif HTTP/1.0” 280 786 The data confirms the following: 1. The timestamp 01Jul 1995.00:00:12 occurs two times. 2. The timestamp 01Jul 1995:00:00:14 accurs three times. 3. The tirnestarmp 01iJul 1995:00:D0:15 occurs two times. Strip the brackets and time zones from the three timestamps occurring more than once and append them to the output file. Show transcribed image text In this challenge, read a text file and capture a timestamp from each line of text. Then create a text file with a list of all timestamps that occur multiple times, each on its own line. Naming convention and a data description are as follows: Naming convention: You will be provided with an input file name called ename. Your output filename should be req filename aplace filename). Data description: Each line of the .txt file contains a single lag record for July 1995 with the following columns in order: 1. The hastname of the host making the request. 2. This columns values are missing and descnbed by a hyphen (Le..J. 3. This column’s values are missing and descnbed by a hyphen fi.e., 4. A timestamp enclosed in square brackets following the format DDimmmYYYYHHMM SS-0400j, where DD is the day of the month, mmm is the name of the month, YYYY is the year, HH:MM SS is the time in 24-hour format, and -0400 is the tirne zone. 5. The request, enclosed in quotes (e.g., ‘GET Simages/NASA-logosmali.git HTTP T.0) 6. The HITP resporise code 7. The total number of bytes sent in the response. For example, given the following log record: to1/3u1/1995:8:00:12 -081 “GET /shuttle/countdown/viden/1ivevideo.gif HTTP/1.o” 280 burger.letters.com – – [ We can label each columin in the record like so: Request Bytes HTTP Rcponse Code 3Jul 1995:CC::2-0400 200 burger.lectes.com Given a string, ilenarrne, that denotes the name of a rual text file, create an output file named req filename to store timestamp records. Each line of the output file must contain a timestamp in the forrnat DD Y yY:HHIM SS for any timestamp that appears in more than one request in filename. The line order in the output file does not matter. Constraints The log file contains no more than 2x 105 records.
Sample Input hosts_access log 08.txt Sample Output Given Mename = “hosts access og 00.txt”. process the records in nosts access g 00. txt and create an output file named req hosts access 09-00 txt c the following rows: 81/Ju1/1995:08:80:12 81ul/1995:0B:00:14 ล1/Jul /1995 : 08:00:15 Explanation 0 The lag file hasts_access lag 00.txt contains the following log records: unicomp6.unicomp.net –[81/Jul/1995:00:00:06 -0408] “GET /shuttle/countdown/ HTTP/1.8″288 3985 burger.letters.com [01/3ul/1995:80:00:11 0480] “GET /shuttle/countdown/Liftoff.html HTTP/1.8″304 8 burger.letters.com[01/3uL/1995:80:00:12 0480] “GET/images/NASA-logosmall.gif HTTP/1.8” 3848 burger.letters.com [01/3uL/1995:00:00:12 0480] “GET shuttle/countdown/video/livevideo.gif HTTP/1.8″ 208 0 d104.aa.net — [01Jul/1995:00:00:13 -040″GET/shuttle/countdown/ HTTP/1.0” 200 3985 unicomp6.unicomp.net – – [01/Jul/1995:80:00:14 -848 “GET /shuttle/countdown/count.gif HTTP/1.” 208 48310 unicomp6.unicomp.net – – [01/Jul/1995:80:00:14 -8481 “GET images/NASA-logosmall.gif HTTP/1.8” 200 786 unicomp6.unicomp.net – – [01/Jul/1995:80:00:14 -8481 “GET /images/KSC-logol.gif HTTP/1.” 280 1284 d104.aa.net – ø1/Jul/1995:08:08:15 -0401 “GET /shuttle/countdown/count.gif HTTP/1.8” 288 40310 d104.aa.net – [01/Jul/1995:08:08:15 -0400] “GET /images/NASA-logosmall.gif HTTP/1.0” 280 786 The data confirms the following: 1. The timestamp 01Jul 1995.00:00:12 occurs two times. 2. The timestamp 01Jul 1995:00:00:14 accurs three times. 3. The tirnestarmp 01iJul 1995:00:D0:15 occurs two times. Strip the brackets and time zones from the three timestamps occurring more than once and append them to the output file.

Expert Answer


Answer to In this challenge, read a text file and capture a timestamp form each line of text. Then create a file with a list of al…

OR