Data Science Zero to Hero - 2.2: Data ETF (Extract, Transform, Load)
Tags: ai, machinelearning, beginners, datascience
Published: 2023-08-12 14:46:22

## Where does data come from?
Data can come from many different sources - it might be generated by users, collected from sensors, retrieved from databases, even scraped from websites. The methods of data collection may depend on the nature of the data source, and the process of managing this data and making it usable for analysis often involves ETL (Extract, Transform, Load). In many cases, *extracted* raw data is not *loaded* directly into a database; It has to be cleaned and *transformed* before it is suitable for machine learning.

- **Extract:** Data is pulled from various sources like databases, sensors, or online services.
- **Transform:** The extracted data is then cleaned and transformed into a suitable format. This might include handling inconsistencies, converting data types, aggregating information, and more.
- **Load:** Finally, the cleaned and structured data is loaded into a destination system such as a database where it can be accessed and analyzed.

![etl](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fh3gzmxk0czgenn73uu8.png)
## Data Extraction Tools
The choice of an ETL tool should be guided by the specific needs of a project. For example, Amazon Kinesis is a powerful tool for real-time data streaming and analytics, often used in the extraction phase of ETL for AWS environments. It's designed to handle large-scale data like video, audio, application logs, and more. Kinesis can ingest massive amounts of information at high speed. This real-time processing allows for immediate insights and responsiveness, distinguishing Kinesis from traditional batch-based ETL tools. 

Kinesis is an ETL tool that might be best used in an AWS environment, but there are other options depending on your needs. To name a couple, you might consider Apache Kafka, a great fit for high-throughput real-time data processing or Microsoft SQL Server Integration Services (SSIS), designed for businesses embedded in the Microsoft ecosystem. There's tons of tools out there, each with their own benefits.

![catmeme](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8da6mlj7ndmqwl21c5zl.png)

## Data Transformation Tools
The choice for a transformation tool is again dependent on your needs.
Apache Spark excels in rapid transformations with in-memory processing, while Microsoft's Power Query is favored for Excel and Power BI with its graphical interface. AWS Glue, a fully managed ETL service, offers a serverless data integration service that simplifies and automates the transformation process. Again with benefits and drawbacks for each, the choice hinges on data size and complexity, processing speed, and user expertise.

## File Formats and Storage Solutions
So far we've covered extracting and transforming data, but what exactly are we trasnforming it into? Well data comes in various formats, each catering to different requirements and use-cases. The chosen file format often influences the way data is stored and managed in databases. Here's a look at some common file formats and corresponding storage solutions:

### CSV, Excel, Parquet, and ORC Files
For structured data, CSV, Excel, Parquet, and ORC files are popular choices. CSV and Excel are simple, human-readable, and can be easily manipulated using spreadsheet software. Parquet and ORC are columnar storage formats designed for efficiency. These file formats are often used for storing tabular data in **Relational Databases** like MySQL and PostgreSQL, which provide robust querying capabilities, data integrity, and scalability.

### JSON, XML, Avro, and Protobuf
JSON (JavaScript Object Notation), XML (eXtensible Markup Language), Avro, and Protobuf are commonly used for semi-structured data. These formats allow hierarchical data representation, making them suitable for complex data structures. They are widely used in web development, API responses, and configuration files, and can be stored in **NoSQL Databases** like MongoDB, DynamoDb, or Cassandra, offering more flexibility in data models and allowing for horizontal scaling.

### Images, Audio, Video Files, and HDF5
Unstructured data often takes the form of multimedia files like images, audio, videos, and large numerical data like HDF5. They may require specialized preprocessing techniques such as feature extraction, image recognition, or natural language processing (NLP) to be utilized in machine learning models. These types of files are typically stored in Object Storage Systems like AWS S3, Azure Blob Storage, or Google Cloud Storage. These systems are commonly used for large, **unstructured datasets** and provide scalability, particularly useful when working with big data.

## Conclusion
The world of data isn't just about having it; it's about molding it in a way that extracts its maximum potential. This requires both a deep understanding of the available tools and an intricate knowledge of the data itself. Each transformation step can potentially unlock new insights or, if done incorrectly, can lead to misguided conclusions.

We now know the basic flow of ETF and its place in the ML Cycle, but there are still questions to be answered. What kind of transformations are most impactful for specific datasets? How do these transformations vary when dealing with structured versus unstructured data? And, are there transformations that universally benefit every dataset or are some uniquely tailored for specific contexts? These are all questions that I am to explain in the following posts in section 2 of this series.

Thank you for reading!