I am completely new to python
I have an excel sheet as below:
Column A Column B Column C Column D Row 1 Mathew abc 89499052 17895077 Row 2 Job def 89499158 17920464 Row 3 Robin ehj 89499254 17901346 Row 4 Sumof(C1+c2+c3) Sumof(D1+D2+D3) Row 5 Result of D4/C4
I need a code snippet for below:
1. Open the excel sheet in certain path(E:/Excelfiles/abc.csv)
2. Find the required values C4 and D4.
3. Find value of C5.
Can someone please help me out?
Sure, you should use Pandas.
import pandas as pa
df = pa.read_csv('E:/Excelfiles/abc.csv')
cSum = df['Column C'].sum()
dSum = df['Column D'].sum()
d4 = df['Column D'].iloc[3]
c4 = df['Column C'].iloc[3]
I let you find the code left. Please check the read_csv function as it may need the encoding parameter depending on your csv file. You will need to learn Pandas Doc Tutorial Article Book R in Python CookBook
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.