GitHub user dentiny added a comment to the discussion: [Question] How to 
generate manifest files and manifest list

I confirm the following python version works:
```python
import os
from pyiceberg.catalog import load_catalog
from pyiceberg.schema import Schema
from pyiceberg.types import IntegerType, NestedField
from pyiceberg.exceptions import NoSuchNamespaceError, NoSuchTableError
import pandas as pd

# 1. Set up catalog
catalog = load_catalog(
    "local",
    **{
        "type": "sql",
        "uri": f"sqlite:///{os.getcwd()}/iceberg_catalog.db",
        "warehouse": f"file://{os.getcwd()}/iceberg_warehouse",
    }
)

# 2. Create namespace if it doesn't exist
namespace = "default"
try:
    catalog.list_tables(namespace)
except NoSuchNamespaceError:
    print(f"Creating namespace: {namespace}")
    catalog.create_namespace(namespace)

# 3. Define schema
schema = Schema(
    NestedField(field_id=1, name="value", field_type=IntegerType(), 
required=True)
)

# 4. Create or load table
table_name = "default.numbers_table"
try:
    table = catalog.create_table(table_name, schema)
    print(f"Created new table: {table_name}")
except Exception as e:
    table = catalog.load_table(table_name)
    print(f"Loaded existing table: {table_name}")

# 5. Insert data
df = pd.DataFrame({"value": [1, 2, 3, 4, 5]})
table.append(df)

# 6. Read data
print("\nTable contents:")
for record in table.scan().to_arrow():
    print(record["value"].as_py())
```

GitHub link: 
https://github.com/apache/iceberg-rust/discussions/1232#discussioncomment-12906212

----
This is an automatically sent email for issues@iceberg.apache.org.
To unsubscribe, please send an email to: issues-unsubscr...@iceberg.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to