What is your input data?
Json-Data looks like your example.
For example, this is csv:
All decimals and integers are str objects. To use them for sorting or to make calculations with them,
you need to cast the
Json-Data looks like your example.
For example, this is csv:
surname,name,gender,growth Musk,Elon,m,183 Holmes,Enola,f,175 Brown,Lilly,f,178 Lothbrok,Ragnar,m,189 Smith,Adreana,f,173 Moon,Larry,m,184Example to open the csv file:
import csv rows = [] with open("your_file.csv", encoding="utf8", newline="") as fd: for row in csv.DictReader(fd): print(row) rows.append(row) # adding the dict to rowsKeep in mind that everything from csv-reader is a
str
.All decimals and integers are str objects. To use them for sorting or to make calculations with them,
you need to cast the
str
to int
or float
.import csv rows = [] with open("your_file.csv", encoding="utf8", newline="") as fd: for row in csv.DictReader(fd): row["growth"] = int(row["growth"]) # str -> int print(row) rows.append(row) # adding the dict to rowsThe other question is: From where are the student numbers (which are also str in your example)?
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
All humans together. We don't need politicians!