'iat returns too much info
I'm trying to create a program that looks for a cell value with a specific name (A1 for example). When it finds it, it takes a value from a cell in the same row and another value from a cell in a different sheet.
my problem is that when I try and use iat[] it returns the value that I want, but with some extra data that I don't know where it gets it from.
import re
import pandas as pd
import csv
import sys
rows = pd.read_excel(r'DSF test.xls', sheet_name='Raw Data', usecols="A")
lr = rows.index[-1]+2
#this is what value you are looking for in the data
for m in ("A"):
for n in range(1,5):
well = m+str(n) #this creates A1 for example
for i in range(0,110):
dfwell = pd.read_excel(r'DSF test.xls', sheet_name='Raw Data', header=7, usecols="A")
vrst = dfwell.loc[i].to_string(index=False)
if vrst == well:
dfreading = pd.read_excel(r'DSF test.xls', sheet_name='Raw Data', header=7, usecols="F")
csvreading = dfreading.loc[i].to_string(index=False)
c = 4
dftemp = pd.read_excel(r'DSF test.xls', sheet_name='Melt Region Temperature Data', header=7)
csvtemp = dftemp.iat[i,c]
c += 1
print(csvtemp)
csvdata = csvtemp + "," + csvreading
filename = well + ".csv"
with open(filename, "a", newline="") as f:
thewriter = csv.writer(f)
thewriter.writerow([csvdata])
f.close()
Also the program is very slow to run but I'm trying to make it do what I want first and I'll optimize it later.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
