What Is Athena?

Athena is a serverless query service that lets you run standard SQL queries on data stored in Amazon S3. It handles structured, semi-structured, and unstructured data alike — making it ideal for querying large datasets and data lakes without managing any infrastructure.

A database in Athena is simply a logical grouping for the tables you create. The actual data stays in S3; Athena reads it on demand.

In this guide, you will learn how to connect CSV data in an S3 bucket to an Athena database using the AWS Glue Crawler. The crawler automatically catalogs your data and infers the correct schema, so you don't have to define columns manually.

Step-by-Step Guide

1 Open Athena and Select Your Database

Open the Athena console from your AWS dashboard. Toggle to the database where you want to create the table, then click Create table.

2 Choose “From AWS Glue Crawler”

You will see two options. Click “from AWS Glue Crawler” to let AWS automatically detect columns and data types. The other option — “from S3 bucket data” — requires you to enter columns manually.

After selecting the Glue Crawler option, you will be redirected to the AWS Glue console to define your crawler.

3 Name Your Crawler

Enter a descriptive name for the crawler, then click Next.

4 Set the S3 Data Source Path

Leave every other setting at its default. In the data source field, enter the S3 bucket path where your CSV file is located.

Important

Make sure you add a trailing forward slash (/) after the directory path. For example:

s3://your-bucket-name/your-folder/
5 Skip Additional Data Stores

When prompted to add another data store, select “No” and continue.

6 Create an IAM Role

On the IAM role screen, choose “Create an IAM role” to generate a new role with the necessary permissions for the crawler. Then click Next.

7 Run the Crawler

Once the crawler is created, locate it by name in the Glue Crawlers list. Select it and click Run Crawler. The crawler will read your CSV file in S3, infer the schema, and create a corresponding table in your Athena database.

The Comma Pitfall

Warning — CSV Formatting

A comma (,) anywhere within a row of your CSV file will disrupt the Athena table. Because CSV uses commas as column delimiters, any extra comma in your data will cause Athena to split that row incorrectly — resulting in misaligned or corrupted data.

Best practice: Before uploading to S3, replace all comma characters within your data values with spaces (or another safe delimiter). This ensures Athena will parse every row correctly.

Below is an example of the original data exported from Excel:

And here is what happens when that CSV is ingested into Athena without removing the embedded commas. The data is returned as unstructured — columns are shifted, rows are broken:

Resolution

Replace all comma characters in every row of your CSV files, then re-upload the cleaned file to S3. Once the commas are removed, Athena will provision the table correctly with proper column alignment.

Key Takeaways
  • Athena is serverless — no infrastructure to manage. Your data stays in S3 and Athena queries it on demand.
  • Use AWS Glue Crawler to automatically detect schema and create tables instead of defining columns manually.
  • Always add a trailing slash to your S3 path when configuring the crawler data source.
  • Create a dedicated IAM role for the crawler with the appropriate S3 read permissions.
  • Commas in CSV values will break your table — replace them with spaces before uploading to S3.
  • Verify your data in the Athena query editor after the crawler completes to confirm the schema is correct.

Conclusion

That covers the full process. By using AWS Glue Crawler, you avoid the tedious work of manually defining table schemas — the crawler reads your CSV, infers the data types, and creates a queryable table in Athena automatically.

The one thing to watch for: embedded commas in your data. Clean them out before uploading, and Athena will handle the rest.

Originally published on Medium. This version is maintained on the CNDRO blog for easier reference. Read the original article →
Need help with your data?

Let CNDRO build the data infrastructure your business needs

From data pipelines to analytics platforms — we engineer the backend so you can focus on growth.

Book a free consultation