I am currently learning SQL/Python, I often just wanted to know the headers and how many rows are in a CSV file, so I just wrote a small Python script for it.
import csv
import readline
readline.set_completer_delims(' \t\n=')
readline.parse_and_bind("tab: complete")
def csvOpen(file):
with open(file, "r", newline='', encoding='utf-8-sig') as csvfile:
reader = csv.reader(csvfile)
i = next(reader)
dRows = sum(1 for line in reader)
print(f"You have {dRows} rows in the CSV file:\n" f"Your headers are:\n {i}")
file = input("Please enter the filename to show the CSV headers: ")
csvOpen(file)
I also have an alias for it in my .bash_aliases.
alias sqhead='python /home/user/Coding/Py-Code/sqlHead.py'