Infer schema eliminating leading zeros.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2024 12:00 AM
Upon reading a CSV file with schema inference enabled, I've noticed that a column originally designated as string datatype contains numeric values with leading zeros. However, upon reading the data to Pyspark data frame, it undergoes automatic conversion to integers, resulting in the removal of the leading zeros.
How can I resolve this issue without passing the external schema while reading.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2024 04:51 AM
if you set .option("inferSchema", "false") all columns will be read as string.
You will have to cast all the other columns to their appropriate type though. So passing a schema seems easier to me.