This is suppose to be done inPython Problem 2 - Parse string for datetime Write a program
Fantastic news! We've Found the answer you've been seeking!
Question:
This is suppose to be done inPython
Transcribed Image Text:
Problem 2 - Parse string for datetime Write a program to read through the text file mbox-short.txt. Examine each line in the file in a loop. For the lines that start with "Date:", get the date and time part of the string, use datetime.strptime() to convert it to a datetime object and print out the result. Note that the datetime has 2 types of formats 1. Sat, 05 Jan 2008 09:14:16 2. 2008-01-05 09:12:07 Your code needs to check which type the date is and use appropriate format string to perform the conversion. Be careful that space are not at the beginning or end of the string so the conversion can be successful. Keep a counter to know how many dates are in this log. Print out the counter. Below is an example of first 5 lines of the output. And the total number of dates 54. 2008-01-05 09:12:18 2008-01-05 09:12:07 2008-01-04 18:08:57 2008-01-04 18:08:50 2008-01-04 16:09:02 ... 54 Problem 2 - Parse string for datetime Write a program to read through the text file mbox-short.txt. Examine each line in the file in a loop. For the lines that start with "Date:", get the date and time part of the string, use datetime.strptime() to convert it to a datetime object and print out the result. Note that the datetime has 2 types of formats 1. Sat, 05 Jan 2008 09:14:16 2. 2008-01-05 09:12:07 Your code needs to check which type the date is and use appropriate format string to perform the conversion. Be careful that space are not at the beginning or end of the string so the conversion can be successful. Keep a counter to know how many dates are in this log. Print out the counter. Below is an example of first 5 lines of the output. And the total number of dates 54. 2008-01-05 09:12:18 2008-01-05 09:12:07 2008-01-04 18:08:57 2008-01-04 18:08:50 2008-01-04 16:09:02 ... 54
Expert Answer:
Posted Date:
Students also viewed these programming questions
-
Discuss sources of revenues Explain the importance of prices and volume in revenue budgeting Clarify why revenues are often ignored in nursing budgets Discuss when revenues should be considered in...
-
As a practicing engineer in manufacturing, why would you be interested in the shape of the curve shown in Fig. 7.7? Explain.
-
Interpretation of Regression Coefficient The cost accountant of the Smart Company has applied regression analysis to a study of repair and maintenance costs in a plant. The resulting estimating...
-
Which of the following is not a way to develop a standard cost? a. By using a fixed rate that is higher every period. b. By performing time and motion studies. c. By analyzing past data. d. By using...
-
Beatriz Janke, president and owner of Jaguar Enterprises, applied for a $300,000 loan from First National Bank. The bank requested financial statements from Jaguar Enterprises as a basis for granting...
-
Required information [The following information applies to the questions displayed below.] Tyrell Company entered into the following transactions involving short-term liabilities. Year 1 April 20...
-
ZnO have polymorphs of wurtzite and zincblende. The spacegroup for wurtzite ZnO is P63mc. Answer following questions. x) (a) What is Bravais lattice and point group of wurtzite ZnO? Explain the...
-
You measure the velocity of falling object at several times given in the table below. Time (s) Velocity (m/s) 0.00 0.10 0.20 0.30 0.40 0.50 0.60 0.70 0.80 0.90 1.00 The acceleration is the slope of...
-
41. 42. The following table lists data collected during a recent experiment. In this case, x represents age (in years) and y represents the given diameter (in inches). 3 5 7 11 13 y 5.73 6.44 7.01...
-
Using the slope formula, compute the slope of the line that goes through (17, 5.5) and (16,-5). Slope 22.5/21 Not equivalent. Now find the equation of the line in the form = mx + b. Equation Nope....
-
A neutral lithium atom is ionized, losing an electron to form Li* and resulting in a decrease in its atomic size. The ionization energy required to do this is 520kJ/mol. If we were to remove a second...
-
A physical examination was used to scan for breast cancer in 2500 women with biopsy proven adenocarcinoma of the breast and 5000 age and race matched control women. The result of the physical...
-
Cash book of Buddies Cafe on 30 April 2021 shows a credit balance amounted RM29,040. However, bank statement balance shows a debit balance of RM16,944. Detailed examination of the two records...
-
Burberrys competitive advantage is through its differentiation strategy. What risk should Burberry remain aware of?
-
Write the schemes similar to (4.4), (4.9), and (4.10) for \(\partial u /\left.\partial y ight|_{i, j}\).
-
Write the schemes similar to (4.17), (4.18), and (4.19) for \(\partial^{2} u /\left.\partial y^{2} ight|_{i, j}\).
-
Write the central finite difference formulas of the second order for \(\partial u / \partial x\) and \(\partial^{2} u / \partial x^{2}\) of function \(u(x, y, t)\) at the grid point \(\left(x_{i+1},...
Study smarter with the SolutionInn App