If your data follows well thought out rules it will be easier for others to use. Don't worry too much over which seperator you choose (comma or double space), worry more that the seperator meaning is preserved through out your data. Similarly, you might believe you have found the perfect data format (Ascii, XML, JSON, .mat) that meets everyone's needs, but in any scientific eniviornment it is almost guarenteed that the data will have to be put in another format at some point. Once the data format is set, write down a description (schema) somewhere. This is tedious but well worth it in the long run.
# here is a code example
from pyMez import *
header=['Measurement_Timestamp = 2016-11-16 21:07:47.252000',
'DMM_reading = 2.809244E+1',
'IFBW = 3.000000E+2',
'IFBW.units = Hz',
'Power = -2.000000E+1',
'Power.units = dBm',
'column_units = [GHz,None,None]',
'Comments = Q26Ra_g5 and the Song wafer with the pdms roof and su8 microfluidics. NDO, 2015/II/pg111, -20db']
column_names=['Frequency', 'reS11', 'imS11']
data=[[1,-.012, .012],
[1.11, .014, .015],
[1.12 , .015, .031]]
table=AsciiDataTable(None,header=header,column_names=column_names,
data=data,comment_begin='!',comment_end='\n',column_names_delimiter=',',
column_names_begin_token='!',column_names_end_token='\n',data_delimiter='\t',
treat_header_as_comment=True,data_table_element_separator=None,
specific_descriptor="Example")
print("The table name is {0} \n".format(table.path))
print("*"*80+"\n")
print table
For example this is equally as good
table.options["data_delimiter"]=","
table.options["comment_begin"]="#"
table.path=table.path.replace("Example","One_Port_SParameter")
print("The table name is {0} \n".format(table.path))
print("*"*80+"\n")
print table
xml_table=AsciiDataTable_to_XMLDataTable(table)
print("The table name is {0} \n".format(xml_table.path))
print("*"*80+"\n")
print xml_table
data={"Data_Description":structure_metadata(string_list_collapse(header)),
"Data":table.get_data_dictionary_list()}
xml_table_2=DataTable(None,data_dictionary=data)
print xml_table_2
from IPython.display import HTML,display
display(HTML(xml_table_2.to_HTML(os.path.join(TESTS_DIRECTORY,"../XSL/DEFAULT_MEASUREMENT_STYLE.xsl"))))
string="""
#Measurement_Timestamp = 2016-11-16 21:07:47.252000 ; DMM_Reading = 2.809244E+1; IFBW = 3.000000E+2;
#IFBW.units = Hz ; Power = -2.000000E+1;Power.units = dBm;
#Comments = Q26Ra_g5 and the Song wafer with the pdms roof and su8 microfluidics. NDO, 2015/II/pg111, -20db"""
def structure_metadata(header_string,metadata_fact_delimiter=";",metadata_key_value_delimiter="=",comment_character="#"):
"""Strucutre Metadata returns a metadata string and returns a metadata dictionary"""
string_list=re.split(metadata_fact_delimiter+'|\n',header_string.replace(comment_character,''))
metadata_dictionary={}
for string in string_list:
pair=string.split(metadata_key_value_delimiter)
#print pair
#print len(pair)
if len(pair)==2:
key=pair[0].rstrip().lstrip().replace(".","_")
value=pair[1].rstrip().lstrip()
metadata_dictionary[key]=value
return metadata_dictionary
print structure_metadata(string)