Forum Discussion
Pipeline Copy activity CSV to Parquet issue
I have a CSV file in my Lakehouse. When I use the Copy Activity to move it and change the format to Parquet, I see columns with null values, although the CSV file is configured correctly (with escape and quote characters)!!
i tried both to load file to table in lakehouse and read it as parquet using spark and in both it shows the null columns !!!
I found the issue to be that many rows with null values were intentionally added to the CSV, and after partitioning, the nulls were the first to be seen.
8 Replies
- lbendlinSuper User
Does your CSV file contain quoted row delimiters?
- AnonymousNot applicable
Hi A_monged ,
Thanks for the reply from lbendlin .
I used PySpark statements in notebook to convert CSV files from lakehouse to parquet files:
# start SparkSession from pyspark.sql import SparkSession spark = SparkSession.builder.appName("CSV_to_Parquet").getOrCreate() # load CSV file df = spark.read.format("csv").option("header","true").load("Files/orders/2019.csv") df.show() # transform to Parquet form and save it parquet_file_path = "Files/test.parquet" df.write.parquet(parquet_file_path)Works fine, as shown below, and my file does not contain null values:
The error may occur because the data types and schemas defined in the CSV file do not match the data types and schemas expected by the Parquet format.
Optionally, you can use the same method as I did to convert the CSV file to a Parquet file.
If you want to save it as a table you can use the following syntax:
df.write.mode(“overwrite”).saveAsTable(“parquetTestTable”)If you have any other questions please feel free to contact me.
Best Regards,
Yang
Community Support TeamIf there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!- A_mongedFrequent Visitor
I tried your approach but still got the same null columns attached table output and sample rows of raw CSV file