imports csv files automatically

Asked

Viewed 28 times

0

I have a list of several csv files in a single directory it happens that every 5 min more file enters this directory

file example:

Det_export_lol-Sla_traceroute_active_test_5_mins_2020-12-10_18_23_00.csv Det_export_lol-Sla_traceroute_active_test_5_mins_2020-12-11_18_28_00.csv Det_export_lol-Sla_traceroute_active_test_5_mins_2020-12-11_18_33_00.csv Det_export_lol-Sla_traceroute_active_test_5_mins_2020-12-11_18_38_00.csv

these files every 5 min creates a new.

i need to insert a file of this in python do the regex treatment I’ve done and then save with another name

but automatically ex

enters: Det_export_lol-Sla_traceroute_active_test_5_mins_2020-12-10_18_23_00.csv treats (already ready the code) volley

enters Det_export_lol-Sla_traceroute_active_test_5_mins_2020-12-11_18_28_00.csv treats (already ready the code) volley

  • Read about design patterns (Pattern design) specifically about observable and observable (Observer)

1 answer

2

You can use the listdir function of the

import the

files = os.listdir('Folder path')

this function will return a list containing all the files within that folder. You can create a function to take this file and compare it to the one you already used and use the Schedule library This Schedule is not native to python you will have to download from Pip.

import schedule
import time

schedule.every(5).minutes.do('A sua função')

while True:
    schedule.run_pending()
    time.sleep(1)

the library documentation https://schedule.readthedocs.io/en/stable/ You can also watch Eduardo Mendes live that talks about this library https://www.youtube.com/watch?v=FjJ1bClIa-o

Browser other questions tagged

You are not signed in. Login or sign up in order to post.