File size: 858 Bytes
a906372 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
#!/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.")
|