#!/usr/bin/env python

from __future__ import print_function, division
import os
import numpy as np
import pandas as pd

GAIADIR = os.getenv('GAIADATA', os.path.expanduser('~/.gaia'))

try:
    df = pd.read_csv(os.path.join(GAIADIR, 'TgasSource_000-000-000.csv.gz'))
except IOError:
    print('Please download all Tgas*.csv.gz files and put them in $GAIADIR, or ~/.gaia, then try again.')
    raise

for i in range(1,16):
    filename = os.path.join(GAIADIR, 'TgasSource_000-000-0{:02.0f}.csv.gz'.format(i))
    #print(filename)
    df = df.append(pd.read_csv(filename))
df.to_hdf(os.path.join(GAIADIR, 'TgasSource.h5'), 'df')

