def main(table,args,shell=False): altered=False if(args.types is not None): types=[x.strip() for x in args.types.split(",")] for x in range(len(types)): table.typecast(x,types_dict[types[x]]) altered=True if(args.rename is not None): names=args.rename.split(",") for x in range(len(names)): colindex=table.findcol(x) if colindex is not None: table.renamecol(colindex,names[x]) altered=True if args.add_col is not None: for i in args.add_col.split(","): cols = i.split(":") if len(cols)<2: print "invalid column : "+i name=cols[0] exp=":".join(cols[1:]) func=mathval.parse(exp) table.addcol(name,func.apply(table)) altered=True if(args.where is not None): func=mathval.parse(args.where) func=func.apply(table) table.select(func) altered=True if(args.select is not None): table.project(args.select.split(",")) altered=True if(args.overwrite): table.save() print("Saved to: "+table.filepath) if(args.printout): print(table) elif(args.iterate): if altered or shell: newname=avail(basefilename) table.filepath=newname table.save() print("Saved to: "+table.filepath) if(args.printout): print(table) elif(args.output is not None): table.filepath=args.output table.save() print("Saved to: "+table.filepath) if(args.printout): print(table) elif(args.printout or (not args.columns and not args.quit and args.types!=None )): print(table) if args.columns or args.types!=None: print(",".join(table.column_str()))
help='save without overwriting. Will also open latest file.') parser.add_argument('--shell', action='store_true', help='open shell.') parser.add_argument('--history', action='store_true', help='print history in shell mode') parser.add_argument('-q','--quit', action='store_true', help='quit shell.') return parser parser=makeparser() args = parser.parse_args() args.file.close() basefilename=args.file.name filename=basefilename if(args.iterate): filename=avail(filename,last=True) table=eztable(filename) if args.nameless: table.columns=[None]*len(table.columns) def main(table,args,shell=False): altered=False if(args.types is not None): types=[x.strip() for x in args.types.split(",")] for x in range(len(types)): table.typecast(x,types_dict[types[x]]) altered=True if(args.rename is not None): names=args.rename.split(",") for x in range(len(names)):