0
path = "C:\\Users\\Adam\\Desktop\\Stock Trackers\\New Folder\\"

finalDf = pd.DataFrame()

for file in filenames:
    if file.startswith("Stock"): 
        df = pd.read_excel(path+file,usecols="A:D,R",index_col=None) 
        df['Total Received']
        df['Qty Received']=df['Total Received']
        df['InvoicedValue'] = df['Price']*df['Qty Invoiced']
        df['ReceivedValue'] = df['Price']*df['Qty Received']
        df['DeltaQty']= df['Qty Received']-df['Qty Invoiced']
        df['DeltaValue']= df['ReceivedValue']-df['InvoicedValue']
        finalDf = pd.concat([finalDf, df])
        finalDf.to_excel("finalfile12.xlsx")

The above script generates the below:

enter image description here

As you can see, the "Total Received" column is missing and so are columns that directly or indirectly dependent on this. The original files have data for these columns. Also, index_col=None is not removing the index in column A (index_col=False doesn't work either)

wjandrea
  • 28,235
  • 9
  • 60
  • 81
  • Welcome to Stack Overflow! Check out the [tour]. Questions about debugging help need to include a [mre] including complete but minimal code as well as minimal example input and output as text, [not a picture](https://meta.stackoverflow.com/q/285551/4518341). Although, just the process of working through the problem should help. If I were you, I'd start by printing the "Total Received" column for each `df` and make sure it's there. For specifics, see [How to make good reproducible pandas examples](/q/20109391/4518341). For more tips, see [ask]. – wjandrea Dec 16 '22 at 21:02
  • Regarding *"index_col=None is not removing the index in column A"*, are you only looking at `finalfile12.xlsx`? It's going to have an index because you didn't supply `index=False` to `finalDf.to_excel()`. – wjandrea Dec 16 '22 at 21:11

0 Answers0