- Newest
- Most votes
- Most comments
The issue you're experiencing is a common challenge when dealing with CSV files containing complex data structures, especially when fields contain commas and are enclosed in double quotes. Here are some approaches you can try to resolve this problem:
-
Custom CSV Classifier: While you've already attempted this, it's worth double-checking your configuration. Ensure that you've set the quote character as double quotes (") and the delimiter as a comma (,) in your custom classifier. Also, make sure to specify that the columns are quoted.
-
OpenCSVSerDe Configuration: Your approach of modifying the table properties to use OpenCSVSerDe is on the right track. However, the error you're encountering suggests there might be a mismatch between the data types defined in your table schema and the actual data in your CSV files. Double-check that the data types in your Glue Data Catalog table match the data in your CSV files, especially for columns that should be of type LONG.
-
Grok Classifier: Consider using a Grok classifier instead of a CSV classifier. Grok patterns can be more flexible in handling complex data structures. You could create a pattern that recognizes the structure of your CSV, including the quoted fields with commas.
-
ETL Job: If the above methods don't work, you might need to create an AWS Glue ETL job to preprocess your data. This job could read the raw CSV files, parse them correctly (handling the quoted fields with commas), and then write them out in a format that's easier for the crawler to handle.
-
Custom Crawler: As a more advanced option, you could develop a custom crawler that understands the specific format of your CSV files, including how to handle quoted fields with commas.
-
S3 Event Trigger: If preprocessing is unavoidable, instead of manually running a Lambda function, you could set up an S3 event trigger. This would automatically invoke a Lambda function or start a Glue job whenever a new file is uploaded to your S3 bucket, ensuring that all files are preprocessed before the crawler runs.
Remember, the goal is to ensure that your data is interpreted correctly at the time of ingestion. While preprocessing can solve the immediate issue, it's generally better to configure your ingestion process (crawler and classifier) to handle the data format correctly if possible.
Sources
Troubleshoot errors with .csv files and AWS Glue Crawler | AWS re:Post
Work with CSV data in AWS Glue - Amazon Athena
Not able to crawl multiple csvs with same specs to exclude double quotes within each field | AWS re:Post
Athena - Querying S3 file (CSV with JSON objects) | AWS re:Post
Relevant content
asked 6 years ago
asked 2 years ago
asked 3 years ago
- AWS OFFICIALUpdated 5 years ago
