forked from snychka/python-decoding-sensor-data
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathload_data.py
More file actions
24 lines (18 loc) · 788 Bytes
/
Copy pathload_data.py
File metadata and controls
24 lines (18 loc) · 788 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import os
import glob
import csv
#create a function to parse the data
def load_sensor_data(): #defined a function
sensor_data = [] #set variable to an empty list
#create a variable and set it to call the glob.glob() function.
sensor_files = glob.glob(os.path.join(os.getcwd(), 'datasets', '*.csv'))
# Read data files
for sensor_file in sensor_files:
with open(sensor_file, r) as data_file:
data_reader = csv.DictReader(data_file, delimiter = ',')
#load data records -> now that you have access to the data in each file, the next step is to load each record into the sensor_data list
# create a second for look to get access to each record
for row in data_file:
#append each row record to the sens_data list
load_sensor_data.append(row)
print(sensor_data())