I’m new to Python and have been struggling to find any resources on how to perform the below. I’m confident that my data set is a list as wrapping the variable which contains it with print(type(variable)) returns <class 'list'>
The list is formatted as per the below. The data is just an example. The actual dataset is from Python’s yfinance.Ticker.news
[{'Name': 'Tom', 'Address': '33 Cheat Street', 'Born': '343620618', 'Location': 'Newcastle', 'Misc': 'Likes Pizza'}, {'Name': 'Richard', 'Address': '101 High Street', 'Born': '343740083', 'Location': 'Leeds', 'Misc': 'Rock Music Fan'}, {'Name': 'Harry', 'Address': '38 Station Road', 'Born': '343722083', 'Location': 'Manchester', 'Misc': 'F1 is a show, not a sport!'}]
I would like to have it read out as per the below, where the most recent record from the list (according to the ‘Born’ Unix Timestamp) is first and the oldest is last and the data categories included can be filtered as desired. In this case only including Born 1st, then Name and finally Address.
Born: Sat Nov 22 1980 11:21:23
Name: Richard
Address: 101 High Street
Born: Sat Nov 22 1980 06:21:23
Name: Harry
Address: 38 Station Road
Born: Fri Nov 21 1980 02:10:18
Name: Tom
Address: 33 Cheat Street
I’ve been able to use a for loop to break each record into a new line as per the below.
for x in range(len(variable)):
print (str(variable[x]) + "\n")
This makes the items easier to read but I’d like to go further and haven’t been able to find any documentation on how to manipulate a list further.
Any help you can offer would be appreciated.
python --version
Python 3.9.9