Have no idea with python-excel read data file
Posted
by
Protoss Reed
on Stack Overflow
See other posts from Stack Overflow
or by Protoss Reed
Published on 2012-12-10T16:44:04Z
Indexed on
2012/12/16
23:04 UTC
Read the original article
Hit count: 288
I am a student and haven't a big expirence to do this work. So problem is next. I have a part of code:
import matplotlib.pyplot as plt
from pylab import *
import cmath
def sf(prompt):
""" """
error_message = "Value must be integer and greater or equal than zero"
while True:
val = raw_input(prompt)
try:
val = float(val)
except ValueError:
print(error_message)
continue
if val <= 0:
print(error_message)
continue
return val
def petrogen_elements():
"""Input and calculations the main parameters for
pertogen elements"""
print "Please enter Petrogen elements: \r"
SiO2 = sf("SiO2: ")
Al2O3= sf("Al2O3: ")
Na2O = sf("Na2O: ")
K2O = sf("K2O: ")
petro = [SiO2,TiO2,Al2O3,]
Sum = sum(petro)
Alcal = Na2O + K2O
TypeA lcal= Na2O / K2O
Ka= (Na2O + K2O)/ Al2O3
print '-'*20, "\r Alcal: %s \r TypeAlcal: %s \
\r Ka: %s \r" % (Alcal, TypeAlcal,Ka,)
petrogen_elements()
So the problem is next. I have to load and read excel file and read all data in it. After that program have to calculate for example Alcaline, Type of Alcaline etc. Excel file has only this structure
1 2 3 4 5
1 name1 SiO2 Al2O3 Na2O K2O
2 32 12 0.21 0.1
3 name2 SiO2 Al2O3 Na2O K2O
4 45 8 7.54 5
5 name3 SiO2 Al2O3 Na2O K2O
6. … …. …. …
…
…
All excel file has only 5 columns and unlimited rows. User has choice input data or import excel file. First part of work I have done but it stays a big part Finally I need to read all file and calculate the values.
I would be so grateful for some advice
© Stack Overflow or respective owner