minecraft_builds / sql_to_parquet.py
mattismegevand's picture
init commit
a906372
raw
history blame contribute delete
858 Bytes
#!/usr/bin/env python3
import sqlite3
import pandas as pd
import pyarrow as pa
import pyarrow.parquet as pq
def sqlite_to_parquet(sqlite_file, parquet_file):
conn = sqlite3.connect(sqlite_file)
cur = conn.cursor()
cur.execute("SELECT name FROM sqlite_master WHERE type='table';")
tables = cur.fetchall()
df_list = []
for table in tables:
table_name = table[0]
query = f'SELECT x, y, z, block_name as mat FROM "{table_name}"'
df = pd.read_sql_query(query, conn)
df['structure'] = table_name
df_list.append(df)
final_df = pd.concat(df_list, ignore_index=True)
table = pa.Table.from_pandas(final_df)
pq.write_table(table, parquet_file)
conn.close()
if __name__ == '__main__':
sqlite_to_parquet('minecraft_structures.db', 'minecraft_structures.parquet')
print("Conversion to Parquet completed successfully.")