python: process result files after metadata type inference.

This commit is contained in:
Drew Frank 2012-10-11 15:07:24 -07:00
parent b2f8450bf3
commit ed669630c6

View file

@ -101,9 +101,6 @@ def load(_dir, _process=None, _format=None, _stream='stdout',
# Create a DataFrame from the matches. # Create a DataFrame from the matches.
df = pd.DataFrame(matches) df = pd.DataFrame(matches)
if _process and not df.empty:
df['res'] = df.resfile.apply(_process)
df = df.drop('resfile', axis=1)
# Optionally try to convert string argument values to numeric types. # Optionally try to convert string argument values to numeric types.
if _infer_types: if _infer_types:
@ -111,6 +108,13 @@ def load(_dir, _process=None, _format=None, _stream='stdout',
df.to_csv(buf) df.to_csv(buf)
df = pd.read_csv(StringIO(buf.getvalue()), index_col=0) df = pd.read_csv(StringIO(buf.getvalue()), index_col=0)
# Open and process the results. This needs to happen after the type
# infererence phase since the processed results can be arbitrary
# Python objects and might not survive the round-trip.
if _process and not df.empty:
df['res'] = df.resfile.apply(_process)
df = df.drop('resfile', axis=1)
return df return df
def _parse_name(file, sep='\t'): def _parse_name(file, sep='\t'):