Python Forum
User Interaction with Excel sheet
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
User Interaction with Excel sheet
#1
Hi Everyone,

I am new to python and wanted to open the excel file while .py script is running and it should wait for the user to enter the input to the excel file without using any module i.e.,(xlsxwriter,xlswt,xlrd)
Suggestions are welcome.

Thank you,
Shruthi LS
Reply
#2
Are you saying you don't want to use xlsxwriter, xlswt, xlrd, etc.?
Reply
#3
(Jun-14-2018, 12:05 PM)ShruthiLS Wrote: user to enter the input to the excel file without using any module i.e.,(xlsxwriter,xlswt,xlrd)
There is no way to do this without using a connection(or write one yourself),the old was to use win32com.client.
In newer time there has come a lot of better tools than using win32,some do you mention or better OpenPyxl, Pandas, pyexcel.
Reply
#4
Thank you all for the reply,Now I am able to read the excel file by changing to .csv format. But the requirement is as I change the data in the .csv file it should reflect automatically, and that is not happening and my python Interpreter doesn't support any module like I mentioned above. This is the test code attached and this should be integrated with the large module. What are the suggestions to improve the below code so that I can Interact with the .csv file on the fly.

from gi import *
filename=("hello12.csv")
file=open(filename,"r")
lines = file.read()
x = lines.split(",")
for i in range(len(x)):
print(x[i])
Reply
#5
Reading a .csv file does just that, read the file. It's not designed to do anything else.
If you want to interact directly with excel file, use OpenPyxl, Pandas or pyexcel as suggested by snippsat.
Reply
#6
Ok thank you, let me check. And can I pass the file object as an argument for the other function and access the file contents in the other function? Is it possible?? If so,please give me a articles to move forward.
Reply
#7
Read the docs!
pyexcel: https://github.com/pyexcel/pyexcel
pandas: http://pandas.pydata.org/
OpenPyxl: https://openpyxl.readthedocs.io/en/stable/
Reply
#8
Reading a csv from excel is not a the same Excel file formats.
Excel can read and output text file formats as txt,csv ect...
If have csv file can read it as normal file or use csv module.

data.csv:
Output:
Year,Make,Model,Length 1997,Ford,E350,2.34 2000,Mercury,Cougar,2.38
import csv

with open('data.csv') as f:
    data = csv.reader(f, delimiter=',')
    for row in data:
        print(row)
Output:
['Year', 'Make', 'Model', 'Length'] ['1997', 'Ford', 'E350', '2.34'] ['2000', 'Mercury', 'Cougar', '2.38']
Quote:Ok thank you, let me check. And can I pass the file object as an argument for the other function and access the file contents in the other function? Is it possible?? If so,please give me a articles to move forward.
That's no problem,you most explain better what you want do.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Simple linear regression with interaction summary table Andrzej_Andrzej 0 293 Feb-21-2024, 07:44 AM
Last Post: Andrzej_Andrzej
  Split excel file and write output at specific row and set sheet position DSCA 0 1,993 May-12-2022, 07:29 PM
Last Post: DSCA
  Protein interaction chains Amniote 2 2,103 Jun-12-2019, 03:32 PM
Last Post: Amniote
  How to import dats from one sheet to another sheet based on Substring using python Vigneshkumarsakthivel 0 2,364 Sep-05-2018, 01:49 PM
Last Post: Vigneshkumarsakthivel

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020