AcA_intensity_plots_MD/DayCutter.py

36 lines
1.0 KiB
Python

# -*- coding: utf-8 -*-
"""
Spyder Editor
This is a temporary script file.
"""
import os
import pandas as pd
WeekPath = 'D:\AcA Mike Dijkhof\cwa files\Pt203_csv' # path to directory with .csv file of entire week
ScriptPath = 'D:\AcA Mike Dijkhof\Scripts' # path to directory of formules.py
os.chdir(ScriptPath)
import formules
os.chdir(WeekPath)
#%%
for subdir, dirs, files in os.walk(WeekPath):
print(subdir)
os.chdir(subdir)
for i in files:
print(i)
if i.startswith('._'): #skip ._ files that may be present in the folder
continue
df = pd.read_csv(i, header=0, names=['Datetime', 'Acc X','Acc Y', 'Acc Z'], dtype={"Datetime": str, "Acc X": 'float32', "Acc Y": 'float32', "Acc Z": 'float32'}, infer_datetime_format=True)
df['Datetime'] = pd.to_datetime(df['Datetime'])
df['Date'] = [d.date() for d in df['Datetime']]
df = df.reindex(columns=['Datetime','Date','Time','Acc X','Acc Y', 'Acc Z'])
formules.CreateDays(df, i, subdir)
os.chdir(subdir)