I am working with a text data file which I have been able to extract data from as CSV/XLSX using:
import pandas as pd
token = open('file.txt','r')
linestoken = token.readlines()
resulttoken = []
for x in linestoken:
resulttoken.append(x.split())
token.close()
df = pd.DataFrame(resulttoken)
df.to_csv('file.csv', index=None, header=None)
print('done!')
But my file has Keywords to distinguish the data from different sources (such as from different batches of experiments). The structure of the data is as follows
Keyword1
Column 1 Column2 Column3 Column4 ....
Keyword2
Column 1 Column2 Column3 Column4 ....
Keyword3
Column 1 Column2 Column3 Column4 ....
and so on...
With the code I have used, I am only able to extract data divided into different columns, but I want to create sheets in an Excel workbook for each keyword and seed their following relevant data into them. I shall highly appreciate any help in this regard.
Thanks!