I'm new to python and since I'm working with tabular data I was recommended to use pandas to process and structure the data that I'll be working with.
I'm reading this file:
Accel(m/s^2) 0.2518 0.0072 9.8201
Accel(m/s^2) 0.2369 0.0036 9.8201
Accel(m/s^2) 0.2477 0.0048 9.8369
Using the following code:
file_name = '/Users/MT/Desktop/Accel_Data.txt';
accel_data = {
'X': [], 'Y': [], 'Z': []
}
data = pd.read_csv(file_name,sep = '\t');
for line in data:
accel_data['X'].append(line[1])
accel_data['Y'].append(line[2])
accel_data['Z'].append(line[3])
I expected the accel_data
dictionary to look like the following:
{
'X': [0.2518,0.2369,0.2477], 'Y': [0.0072, 0.0036, 0.0048], 'Z': [9.8201, 9.8201, 9.8369]
}
But it looked like this instead:
{
'X': ['c', ':', ':', ':'], 'Y': [ 'c', ' ', ' ', ' '], 'Z': [ 'e', '0', '0', '9']
}
This work could be done in excel or matlab, which I'm more accustomed to using, but I need to learn how to use python to transition into a more versatile coding language for processing this type of data. Any help would be thoroughly appreciated!