Hello friend i have a simple dataframe that reads the csv file and contains the values of the files but here i'm only reading the selected columns which is choose by the user and appending it with the newly added columns This the program:
final_Array=[]# this array have the values of selected colunms
data = pd.DataFrame(final_Array)
data['SrID'] = 'SR' + pd.Series(np.arange(1, len(data.index) + 1)).astype(str).str.zfill(4)
tempColumns = ['Year', 'Month']
tempColumns.extend(targetHeader) # "targetHeader" this contains the headers columns names which will added to the other newly added columns
tempColumns.append('SrID')
result = data
result .to_csv('out.csv')
In this i have created a new columns like year,month,srID, which will be appended with older columns which can be selected by the user on UI.. for example(Asset_Id, Asset Family, Asset Name, Keywords etc..) After computation it will show like this:
Year Month Asset_Id Asset Family Asset Name SrID
1970 Jan 1 Haptic Analyser HAL8 SR0001
1970 Jan 2 Hyperdome Inspector HISP18 SR0002
1970 Feb 5 Superdraft Tunnel STR46 SR0003
1970 Feb 2 Hyperdome Inspector HISP4 SR0004
1970 Feb 3 Nano Dial Assembler NDA18 SR0005
1970 Feb 5 Superdraft Tunnel STR44 SR0006
1970 Feb 4 Geometric Synthe GeoSyn29 SR0007
1970 Feb 1 Haptic Analyser HAL10 SR0008
1970 Feb 5 Superdraft Tunnel STR41 SR0009
1970 Feb 5 Superdraft Tunnel STR33 SR0010
This output i will get when i print in the csv file In simple word i just want to print the "SrID" at the first position in csv file so please tell me one efficient way to do this i have tried many way but its not working please help me...thanks