I have multiple files that are named like this
2018-08-31-logfile-device1
2018-09-01-logfile-device1
in these files the data is sorted this way:
00:00:00.283672analogue values:[2511, 2383, 2461, 2472]
00:00:00.546165analogue values:[2501, 2395, 2467, 2465]
I append all these files into one big dataframe with this code: (i got from here: Import multiple excel files into python pandas and concatenate them into one dataframe)
file_log = os.listdir(path)
file_log = [file_log for file_log in glob.glob('*device1*')]
df = pd.DataFrame()
for file_log in file_log:
data = pd.read_csv(file_log,sep='analogue values:',names=['time',
'col'], engine='python')
df = data.append(data1)
I transform the data and then it looks like this:
analog1 analog2 analog3 analog4 time
2511 2383 2461 2472 00:00:00.283672
2501 2395 2467 2465 00:00:00.546165
2501 2395 2467 2465 00:00:00.807846
2497 2381 2461 2467 00:00:01.070540
2485 2391 2458 2475 00:00:01.332163
but the problem is, I want the time column to be date time, where the date is the date from the filename it came from.
analog1 analog2 analog3 analog4 datetime
2511 2383 2461 2472 2018-08-31 00:00:00.283672
2501 2395 2467 2465 2018-08-31 00:00:00.546165
2501 2395 2467 2465 2018-08-31 00:00:00.807846
2497 2381 2461 2467 2018-08-31 00:00:01.070540
2485 2391 2458 2475 2018-08-31 00:00:01.332163