How do I stop python from appending data to the same row in excel

0 votes

I want to store some website data that I collected in Excel. The procedure is running smoothly, however the issue is that it repeatedly overwrites the fresh data in the first row. I added the data to the excel file using the following code:

Claim_Level.append((head(PDF_FormatType, AR_Configuration_Name, p_dob, Client_Id, p_payor, Provider_Address, p_taxid, p_bpnpi, p_renp, Insurance_Address, CHECK_EFT_Address, CHECK_EFT_Number, p_name, INSURED_NAME, PATIENT_CORRECTED_NAME, Account_Number, Sr_No, p_dos, p_dsub, p_ins, INSURED_CORRECTED_ID, p_ctype, Billed_Amount, Paid_Amount, Total_Contractual_Amount, Deductible_Amount, Coninsurance_Amount, Co_Pay_Amount, Adjustment_Amount, Claim_Status_No, p_cnum, Plan_Name, Claim_Paid_Date, CROSS_OVER_PAYER_NAME, Non_Covered_Amount, Covered_Amount, DRG_Number, DRG_Amount, Total_Allowed_Amount, Medical_Record_Number, Interest, Sequestration_Amount, Total_Patient_Responsibility, Late_Filing_Charge, Payee_ID, Patient_Group_Policy_No, Check_EFT_Date, Previously_Paid, Forwarded_to_Additional_Payer, PATIENT_RESPONSIBILITY_REASON_CODE, ASG, Processed_As, Expected_Reimbursement, p_renp, p_rpnpi, Claim_Status, Inboxes_Name, Category, Queue, Inbox_Description, Unknown_Inbox_Category, OCR_Processed_Date, time, i, xnum)))

csvgenerater = pd.DataFrame(Claim_Level)

with pd.ExcelWriter('OUTPUT_FILE.xlsx', mode=mode) as writer:
.....csvgenerater.to_excel(writer, sheet_name = 'ClaimLevel_Output', index=False)     

The screenshot of the code: enter image description here

I want it to store the data row by row and not overwrite it.

Mar 25, 2023 in Others by Kithuzzz
• 38,000 points
555 views

1 answer to this question.

0 votes
There is no indication in your code as to what value the variable mode has. Ensure sure it is in add mode and has the value "a." Otherwise, an Excel file will be created from the variable csvgenerater.

The existing Excel file can also be read as a DataFrame, a row added, and the DataFrame is then saved as an Excel file.
answered Mar 25, 2023 by narikkadan
• 63,600 points

Related Questions In Others

0 votes
1 answer

How do I set the default paste special in excel to paste only values

I paste the values with a keyboard ...READ MORE

answered Nov 6, 2022 in Others by narikkadan
• 63,600 points
3,527 views
0 votes
1 answer

I have filtered my Excel data and now I want to number the rows. How do I do that?

Solution Filter your data. Select the cells you want ...READ MORE

answered Nov 14, 2022 in Others by narikkadan
• 63,600 points
1,128 views
0 votes
1 answer

How do you populate a google sheets/excel column with cells from a column in another sheet in the same document?

You have two options on chronology: sheet-by-sheet =QUERY({Sheet1!X:Z; Sheet2!X:Z; ...READ MORE

answered Dec 19, 2022 in Others by narikkadan
• 63,600 points
1,628 views
0 votes
1 answer

How can I preserve the format while exporting data from excel to evernote

The contents for an Evernote note are ...READ MORE

answered Jan 5, 2023 in Others by narikkadan
• 63,600 points
1,121 views
0 votes
1 answer

Convert column in excel date format (DDDDD.tttt) to datetime using pandas

Given # s = df['date'] s 0 ...READ MORE

answered Oct 2, 2022 in Others by narikkadan
• 63,600 points
3,586 views
0 votes
1 answer

How to freeze the top row and the first column using XlsxWriter?

You can use worksheet.freeze_panes() to achieve this . There ...READ MORE

answered Oct 11, 2022 in Others by narikkadan
• 63,600 points
2,358 views
0 votes
1 answer

Compare 2 columns in same excel sheet in pandas

Try this: import pandas as pd import numpy as ...READ MORE

answered Dec 16, 2022 in Others by narikkadan
• 63,600 points
2,732 views
0 votes
1 answer

Export DataFrame timedelta column to timestamp Excel column

The reason that the column format isn't ...READ MORE

answered Feb 6, 2023 in Others by narikkadan
• 63,600 points
1,601 views
0 votes
1 answer

Python: How do I get multiple results in the same excel sheet?

Try this: fmin = lambda x: abs(x).min() fmax = ...READ MORE

answered Mar 25, 2023 in Others by narikkadan
• 63,600 points
575 views
0 votes
1 answer

In excel how do I reference the current row but a specific column?

Put a $ symbol in front of ...READ MORE

answered Oct 15, 2022 in Others by narikkadan
• 63,600 points
1,966 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP