Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8966355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:00:36+00:00 2026-06-15T17:00:36+00:00

I am a student and haven’t a big expirence to do this work. So

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T17:00:37+00:00Added an answer on June 15, 2026 at 5:00 pm

    There is this website http://www.python-excel.org/ that lists all the major Python excel related libraries.
    I personally have tried XLRD -the first one listed- and found it great, and it has a neat documentation.

    I have also done some work using it while the Presidential elections took place in Egypt as there were lots of data in an excel sheet that we needed to import into a mysql database. I have published the code on Github : https://github.com/mos3abof/egypt-elections-misc

    First install xlrd

    The script you will come up with should be something like:

    from xlrd import *
    ## Opening the excel file
    book = open_workbook('excel_file.xls')
    
    ## Reading the sheet we need
    ## Most probably the data will be on the first sheet, 
    ## otherwise this needs to be updated
    our_sheet = book.sheet_by_index(0)
    
    ## Get the rows number
    rowcount = our_sheet.nrows
    
    ## Looping over sheet rows
    for i in range(rowcount -1):
        ## Get the data in the row
        our_row = our_sheet.row_slice(i+1)
    
        ## Access each row by index and do whatever you like with it
        ## Since you have 5 columns, the index will range from 0 - 4
        print our_row[0]
        print our_row[1]
        print our_row[2]
        print our_row[3]
        print our_row[4]
    

    You can find a working example from the script I mentioned above in this file : https://github.com/mos3abof/egypt-elections-misc/blob/master/elections_import_excel.py

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have student.xml file and am parsing this file using SAX Parser and now
I'm a student and I have a lot of free time on this vacation
Problem: * I'm trying to calculate the number of consecutive absence each student have
I'm a student and have to work with Java and Eclipse. As we have
EDIT: my revised Entity relationship diagram A Student can have many contact times but
I have a Student and a Teacher model in my app. I want a
I have two student objects. class Student{ int physics; int english; int chemistry; }
I have a Student class in my application as below: public class Student {
I have a student class and every student instance created needs to be stored
I have Class and Student objects. Both have collection of another as property. Which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.