How could you get the first ten data from the last column of a flat file separated by commas?

Python has been selected to create the code that answers this question.
We can code the answer using libraries like Pandas or directly without any package.

Script using Pandas

import pandas as pd
df = pd.read_csv('doc.txt', sep=',', header=None)
df.iloc[:,-1].head(10)

Script from scratch

f = open('doc.txt', 'r')
for i in f:
    print(i.split(',')[-1].split('\n')[0])

 


Your subscription could not be saved. Please try again.
Your subscription has been successful. Thank you for joining this great data world.

GET OUR NEWSLETTER

You'll get the latest posts delivered to your inbox.