In [1]:
name_tran_dict = {
    '03': 'Sensor 1',
    '04': 'Sensor 2',
    '05': 'Wrong Sensor'
}

In [5]:
import pandas as pd
import numpy as np

df = pd.read_csv('./data1.csv', parse_dates=True)

tag_names = df['tagname'].unique() # gets the unique tag names
data_dic = {} # create an empty dictionary (map)

for name in tag_names: # use the unique name to assemble a dictionary, with name as key, value as selected data
    # print(name)
    short_name = name[12: 14]
    translated_name = name_tran_dict[short_name]
    data_dic[translated_name] = df[ df['tagname'] == name]


Vendor:  Continuum Analytics, Inc.
Package: mkl
Message: trial mode expires in 30 days

In [ ]:


In [6]:
data_dic


Out[6]:
{'Sensor 1':                tagname                 time  value1  value2
 6  FL02.X05_Z4103.f_CV  12/12/2016 09:00:30    4.67    0.96
 7  FL02.X05_Z4103.f_CV  12/12/2016 09:01:30    4.77    0.90
 8  FL02.X05_Z4103.f_CV  12/12/2016 09:02:30    4.78    0.27,
 'Sensor 2':                tagname                 time  value1  value2
 3  FL02.X05_Z4104.f_CV  12/12/2016 09:00:30    6.87    0.44
 4  FL02.X05_Z4104.f_CV  12/12/2016 09:01:30    6.88    0.34
 5  FL02.X05_Z4104.f_CV  12/12/2016 09:02:30    6.89    0.92,
 'Wrong Sensor':                tagname                 time  value1  value2
 0  FL02.X05_Z4105.f_CV  12/12/2016 09:00:30    5.90    0.16
 1  FL02.X05_Z4105.f_CV  12/12/2016 09:01:30    5.10    0.45
 2  FL02.X05_Z4105.f_CV  12/12/2016 09:02:30    5.11    0.55}

In [7]:
for group_key in data_dic:
    df_group = data_dic[group_key]
    del df_group['tagname']
    df_group.to_csv(group_key + '.csv', index=False)

In [ ]: