Skip to content

A CLI program that reads and stores CSV file data into PostgreSQL database

Notifications You must be signed in to change notification settings

daveh07/CSV_File_Reader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CSV FILE READER - CLI APPLICATION

A command line application that parses csv files, cleans fields from whitespaces & special characters, validates email address and stores a user table to PostgreSQL

REPL - View Live CLI Application Demo:

Refer to link below to run the code from Repl.it CLI https://replit.com/@daveh87/CSVFileReaderApp?embed=1#main.py

Setup

Clone the repository:

https://github.com/daveh07/CSV_File_Reader.git

Py Version: Python 3.9

Create a virtual environment.

pip3 install psycopg2-binary

To run application, open shell and run in Terminal/Command Line: --file [csv file name]

eg):

python3 user_input.py --file users.csv --help

This will return the help menu and list commands

DATABASE PARAMETERS

  • Username =
  • Host =
  • Password = ""

  • >Example command to create the database table:

    python3 user_upload.py --file users.csv --create_table -u -p '' -h 'localhost'

    Which returns the following PostgreSQL table:

    Schema Name Type Owner
    public users table david

    csv_reader_db=# \d users Table "public.users"

    Column Type Collation Nullable Default
    name character varying(50) not null
    surname character varying(50) not null
    email character varying(250) not null
    Indexes:
    "users_pkey" PRIMARY KEY, btree (email)
    

    NOTE:

    Please feel free to add any contributions!

    What I Learned

  • Parsing and cleaning csv file data
  • Using Regex to validate email addresses
  • Using open source PostgreSQL data base
  • Creating lists of user data to store to PostgreSQL database table
  • Parsed arguments to create Command Line directives using argparse package
  • About

    A CLI program that reads and stores CSV file data into PostgreSQL database

    Resources

    Stars

    Watchers

    Forks

    Releases

    No releases published

    Packages

    No packages published

    Languages