import pandas as pd InputFile = 'location of txt file' read_file = pd.read_csv(InputFile, sep=r'|', names = ['col1','col2'], skipinitialspace=True).fillna('') read_file['sno'] = read_file.groupby(['col1']).cumcount()+1 df = read_file.pivot(index='sno', columns='col1', values='col2').reset_index() df.to_csv('Output Path',index=False)
Thursday, February 4, 2021
Python - Converting Rows values to Columns names
Subscribe to:
Posts (Atom)