Mimi R.

asked • 03/10/22

Using regex to find file location from traceback file

so there’s a trace back log txt file that contains

Traceback (most recent call last):
File "/home/datascience/logs/read_data.py", line 1, in word_count
with open(filename) as f:
FileNotFoundError: [Errno 2] No such file or directory: 'inputfile.txt'
  1. The assignment is to apply the function to return The file path and the line number
/home/datascience/logs/read_data.py
1

I tried using the same method as I used in log.txt but it didn’t work

I tried using re.findall(r’\/.*?\.[\w:]+)’,file)

Ahmed K.

tutor
Hi Mimi. Is using regex required for this assignment?
Report

03/19/22

1 Expert Answer

By:

Chara M. answered • 04/09/22

Tutor
New to Wyzant

Hands-on Programming and Math tutor

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.