I have CSV files with misplaced records issue. I have inferred/final column-datatypes for those files. So, whenever we are getting mismatched datatypes by comparing with final/inferred datatypes, it should read line by line and remove the record(row) with mismatch.
I have the following steps as a requirement,
For example,
1.read csv line by line
2.find the datatype of each column and match with inferred column-datatype
3.if there is mismatch ,then remove the record(row)
otherwise keep all good rows in valid_record_csv file
INFERRED datatypes-column(final datatype) to compare with files.
name: string
date: date
phone: long
col1: integer
col2: double
SAMPLE INPUT csv file
Name date phone col1 col2
124 PANAMA 440894563 0.9800
BB 2022-9-23 449035667 9.08765
BB GRENADA BBCC PASS
SAMPLE OUTPUT csv file:
I have one column empty/blank, but it is having inferred/final datatype as integer. Another one with double datatype
NAME DATE PHONE col1 col2
BB 2022 449035667 9.08765