Solve Data Science Tasks In Python (Saving Hours) (automating import CSV files to database) @stratascratch
Solve Data Science Tasks In Python (Saving Hours) (automating import CSV files to database)  @stratascratch
Uploaded November 2020 | Updated September 2026, 3 days ago
Solving real world data science tasks by automating this common data science task will save you hours of work. I'll cover how to write a python script to import a CSV or Excel file to a database. In this video I’ll specifically be showing you how to import a CSV file to a postgres database on AWS. Importing CSV files to a database is a common task needed for data science and analytics and it can be done completely with python using pandas dataframes, numpy, os library, and the posgres database wrapper psycopg2.

Here's the github repo: github.com/Strata-Scratch/csv_to_db_automation

This python script is completely manual. Part 2 where I completely refactor the python script so that our code can handle multiple files without changing a line of python code can be found here (youtu.be/TDwy1lSjEZo).

This is also my first python video so please leave a comment and let me know what you think. Did I cover the concepts in detail? Do you want more detail? Less? Was the code too small to read? Any feedback would be appreciated!

Topics Covered:
- How to read your CSV file into a pandas dataframe
- How to clean the table name and column headers using methods like replace() and lower()
- How to convert your pandas dataframe to a CSV file
- How to create a database table and import your CSV file to a postgres database on Amazon Web Services (AWS) in python

______________________________________________________________________
Resources:

- How to setup Anaconda: docs.anaconda.com/anaconda/install
- How to install psygopg2: anaconda.org/anaconda/psycopg2

πŸ‘‰ Subscribe to my channel: bit.ly/2GsFxmA
πŸ‘‰ Practice real data science interview questions: platform.stratascratch.com/coding?utm_source=youtube&utm_medium=click&utm_campaign=YT+description+link

______________________________________________________________________
Timestamps:

Intro: (0:00)
Outlining steps & import python libraries: (2:23)
Reading your CSV file as a pandas dataframe: (4:31)
Cleaning your table name: (6:03)
Cleaning your column names: (10:25)
Generating SQL query to create database table: (12:40)
Connecting to your database: (19:04)
Generating SQL queries to import CSV file to database: (21:53)
Double checking file was imported correctly: (30:50)
Conclusion: (31:47)

______________________________________________________________________

Contact:

If you have any questions, comments, or feedback, please leave them here!
Feel free to also email me at nathan@stratascratch.com
______________________________________________________________________
Solve Data Science Tasks In Python (Saving Hours) (automating import CSV files to database)The Full Stack Data Scientist - Python Libraries You Need To KnowUsing Python Pandas for Building Ubers Business Models [Part 3]Facebook and Microsoft Data Science SQL interview question walkthrough (advanced)How To Solve Data Science Probability Interview Questions | Meta/Facebook ExampleA Python Coding Interview Question From AmazonData Science SQL Scenario Based Interview Question [Facebook] - Date ManipulationAmazons Most-Feared Tree Traversal (and its simple solution)Edge Case Alert in Python Interview Question Solving [Part 2]Why Data Engineering Is Better Than Data Science (Seriously, Fight Me)
StrataScratch |

Solve Data Science Tasks In Python (Saving Hours) (automating import CSV files to database)

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER