aboutsummaryrefslogtreecommitdiffstats
path: root/Pre
diff options
context:
space:
mode:
authorVolker Hoffmann <volker@cheleb.net>2015-12-31 21:45:43 +0100
committerVolker Hoffmann <volker@cheleb.net>2015-12-31 21:45:43 +0100
commit691e95d999177ab87c094321f1fb997caaa7e6e4 (patch)
tree24a00a2a2020a70a8ad37d9f7865417862b5b483 /Pre
parentc05a50c8ee01f17e4b3d75c7b6d0f10bbd3adc8a (diff)
feat: loader and converter for astorb fixed-width data files
Diffstat (limited to 'Pre')
-rw-r--r--Pre/astorb2df.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/Pre/astorb2df.py b/Pre/astorb2df.py
new file mode 100644
index 0000000..d06c049
--- /dev/null
+++ b/Pre/astorb2df.py
@@ -0,0 +1,33 @@
+"""
+Load Astorb File into Pandas Dataframe. Store as HDF5.
+"""
+
+import obs_helpers_minor as om
+import pandas as pd
+import argparse
+
+
+# Parse Arguments
+parser = argparse.ArgumentParser()
+parser.add_argument('-fname_in', default='astorb.dat', \
+ help='Name of Astorb Source File.')
+parser.add_argument('-fname_out', default='astorb.hdf5', \
+ help='Name of Target HDF5 File.')
+parser.add_argument('--short', action='store_true')
+args = parser.parse_args()
+
+# Info
+if args.short:
+ print "!! Short Mode. Loading 1000 Objects."
+else:
+ print "!! Loading 670k Objects."
+ print "!! Get Some Coffee (Processing Time ~8 Minutes)."
+
+# Process
+print "// Loading Data (%s)" % args.fname_in
+df = om.load_astorb(fname=args.fname_in, short=args.short)
+
+# Store
+print "// Saving to HDF5 (%s)" % args.fname_out
+with pd.HDFStore(args.fname_out) as store:
+ store["df"] = df