Forum Discussion
Loading CSV table from notebook resources to a delta table in a lakehouse using code snippet
- 1 year ago
Hi Anonymous,
Replace the notebookutils.lakehouse.loadTable block with standard PySpark code using .read() and .saveAsTable() — this is the official, stable, and Fabric-supported approach for loading data from a CSV file to a Lakehouse table.
Microsoft recommends using PySpark APIs in Fabric Notebooks for reading/writing data to Lakehouse tables. The method notebookutils.lakehouse.loadTable() is not part of the documented, supported APIs and is likely either an internal or deprecated utility.
You can use PySpark to load data from CSV, Parquet, JSON, and other file formats into a lakehouse. You can also create tables directly from these DataFrames.
ex:
df = spark.read.option("header", True).csv("Files/YourFolder/yourfile.csv")
df.write.mode("overwrite").saveAsTable("lakehouse_name.table_name")Thanks,
Prashanth Are
MS Fabric community support
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly and give Kudos if helped you resolve your query
Hi Anonymous,
Replace the notebookutils.lakehouse.loadTable block with standard PySpark code using .read() and .saveAsTable() — this is the official, stable, and Fabric-supported approach for loading data from a CSV file to a Lakehouse table.
Microsoft recommends using PySpark APIs in Fabric Notebooks for reading/writing data to Lakehouse tables. The method notebookutils.lakehouse.loadTable() is not part of the documented, supported APIs and is likely either an internal or deprecated utility.
You can use PySpark to load data from CSV, Parquet, JSON, and other file formats into a lakehouse. You can also create tables directly from these DataFrames.
ex:
df = spark.read.option("header", True).csv("Files/YourFolder/yourfile.csv")
df.write.mode("overwrite").saveAsTable("lakehouse_name.table_name")
Thanks,
Prashanth Are
MS Fabric community support
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly and give Kudos if helped you resolve your query