aboutsummaryrefslogtreecommitdiffstats
path: root/Pre
diff options
context:
space:
mode:
authorVolker Hoffmann <volker@cheleb.net>2016-03-02 13:01:17 +0100
committerVolker Hoffmann <volker@cheleb.net>2016-03-02 13:14:15 +0100
commit4c7dbb33a38649ecb28e4b1f52f1f5222e4ccf32 (patch)
tree5fd8fc0ac479fa9cfae6c5b762cc3f78af2d4cb3 /Pre
parent701611e9790cbb6cd2c8037172c09370dcf1b0c4 (diff)
feat: conversion script for Amaury =]
Diffstat (limited to 'Pre')
-rw-r--r--Pre/exo2simple.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/Pre/exo2simple.py b/Pre/exo2simple.py
new file mode 100644
index 0000000..938b749
--- /dev/null
+++ b/Pre/exo2simple.py
@@ -0,0 +1,42 @@
+"""
+Convert Exoplanet.Eu Dump to Simple CSV Format.
+For Gnuplot Lovers and Python Haters.
+Get Dump Here: http://exoplanet.eu/catalog/csv/
+"""
+
+import pandas as pd
+
+# Constants
+mearth = 5.97219e24 # kg
+mjupiter = 1.89813e27 # kg
+Rearth = 6371.0 # km
+Rjupiter = 69911.0 # km
+
+# Source
+# fexo = '/home/ics/volker/ExoEu/exoplanet.eu_catalog_2016-01-11.csv'
+fexo = 'exoplanet.csv'
+
+# Load
+print "// Loading"
+df = pd.read_csv(fexo, header=0)
+df.rename(columns = {'# name': 'name'}, inplace = True)
+# df.mass = df.mass * mjupiter / mearth
+# df.radius = df.radius * Rjupiter / Rearth
+
+# Print Some Data
+print "// SAMPLE OUTPUT"
+print df[['name','star_name','radius','mass',\
+ 'semi_major_axis','eccentricity']].head(3).T
+
+# Export
+# print "// Saving"
+# df.to_csv('exoplanet_simple.csv', \
+# columns=['mass', 'semi_major_axis', 'radius'], \
+# index=False)
+
+# Use this if you want ? in unnamed columns
+print "// Saving"
+df.to_csv('exoplanet_simple.csv', \
+ columns=['mass', 'semi_major_axis', 'radius'], \
+ na_rep='?', \
+ index=False) \ No newline at end of file