xxxxxxxxxx
# On MacOS with python 3.9+ with brew installed use:
brew install python-tk@3.9
xxxxxxxxxx
For Ubuntu or other distros with Apt:
$ sudo apt-get install python3-tk
For Fedora:
$ sudo dnf install python3-tkinter
You can also mention a Python version number like this:
$ sudo apt-get install python3.7-tk
$ sudo dnf install python3-tkinter-3.6.6-1.fc28.x86_64
xxxxxxxxxx
try:
# for Python2
# sudo apt-get install python-tk
from Tkinter import * ## notice capitalized T in Tkinter
except ImportError:
# for Python3
# sudo apt-get install python3-tk
from tkinter import * ## notice lowercase 't' in tkinter here
xxxxxxxxxx
#Importting csv module
import csv
#csv file name
filename= "aapi.csv"
# intiliaze titles and rows
fields =0
rows = 0
# reading csv file
with open(filename,'r') as csvfile:
# extract each data row one by one
csvreader=csv.reader(csvfile)
rows.append(rows)
# get total no of rwos
print("Total no of rows:%d%(csvreader.line_num)")
# print fields name
print('Field names are:' + ', '.join(field for field in fields))
# print first 5 rows
print('\n First 5 rows are:\n')
for row in rows[:5]:
# parsing each column of rows
for col in row:
print("%10s"%col),
print('\n')