I want to create a dataframe from a list, the thing is that my column name is also in the list.
List:
['Input_file_column_name,Is_key,Config_file_column_name,Value\nEmployee ID,Y,identifierValue,identityTypeCode:001\nCumb ID,N,identifierValue,identityTypeCode:002\nFirst Name,N,first_Name \nLast Name,N,last_Name \nEmail,N,email_Address \nEntityID,N,entity_Id,entity_Id:01\nSourceCode,N,sourceCode,sourceCode:AHRWB\n']
Resulting dataframe:
Input_file_column_name Is_key Config_file_column_name Value
0 Employee ID Y identifierValue identityTypeCode:001
1 Cumb ID N identifierValue identityTypeCode:002
5 EntityID N entity_Id entity_Id:01
6 SourceCode N sourceCode sourceCode:AHRWB
How do I convert it? Do I convert the list to a dictionary and then do it or is there a way that it can be done directly?
Code:
import pandas as pd
with open('onboard_config.txt') as myFile:
text = myFile.read()
result = text.split("regex")
print result
df=pd.DataFrame[[sub.split(",") for sub in result]]