Пример #1
0
 def __init__(self,
              stream,
              names=None,
              types=None,
              alltype=None,
              callback=None,
              **kwargs):
     self.f=stream
     self.data=None
     self.callback=callback
     if names is None:
         names=[]
         typed=None
         if types is None:
             types=[]
             typed=False
         cols=self.f.readline().rstrip("\n").split(",")
         for i in cols:
             name=i.strip()
             if not typed and "^" in name:
                 namesparts=name.split("^")
                 names.append(namesparts[0])
                 types.append(types_dict[namesparts[1]])
             elif not typed:
                 names.append(name)
                 types.append(None)
             else:
                 names.append(name)
         if alltype is not None:
             types=[alltype]*len(names)
     else:
         if types is None:
             types=[None]*len(names)
     self.tabledef=eztables.tabledef(names,types,[])
     self.spent=False
Пример #2
0
 def __init__(self,
              stream,
              callback=None,
              **kwargs):
     self.f=stream
     self.callback=callback
     names=[]
     types=[]
     while True:
         line=self.f.readline()
         line=line.strip()
         if len(line)<=0 or line[0]=='%':
             continue
         if line.upper()=="@DATA":
             break
         splits=line.split()
         if splits[0].upper()=="@ATTRIBUTE":
             names.append(splits[1])
             if splits[2].lower()=="numeric":
                 types.append(float)
             else:
                 types.append(None)
     self.tabledef=eztables.tabledef(names,types,[])
     self.spent=False