import csv
import pandas as pd
import os
import glob

os.getcwd()
os.chdir(r'C:\Users\anson\Dropbox\Dissertation\Fracfocus\FracFocusCSV\Fracfocus_raw')


###merge the raw files from FracFocus
filename = 'FracFocusRegistry_'

df_final = pd.DataFrame()

for i in range(1,23):
    df = pd.read_csv("FracFocusRegistry_" + str(i) + ".csv")
    df_final = df_final.append(df)

df_final['date'] = pd.to_datetime(df_final['JobEndDate'],errors='coerce')
df_final['year'] = df_final['date'].dt.year
df_final['month'] = df_final['date'].dt.month

df_final.to_csv('merged_raw_original.csv', index=True, encoding='utf-8-sig')

