Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed last year.
Improve this question
I have excel sheet having one sheet with 4 tables they are placed randomly. Out of the four tables, three tables have column name, except for one. Each table has 4 to 5 rows and 4 to 5 columns. How to extract all the tables without doing hard coding using Python. All tables are separated by some space.
Does this previous question
https://stackoverflow.com/questions/69255564/how-to-extract-different-tables-in-excel-sheet-using-python
help? The example code that can be adapted to just print all tables in all sheets. It does also use pandas.
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
The figure is given to show the output after requesting the URL and removing all the div element tags. I now need to store the data of Area, Bedroom, Location, Price, the floor in a CSV file. So how can I do it I only know python's function and method for doing it and how can I perform Indexing in such output?
Output by some manipulation done in URL request which is to be stored in CSV file
List item
#shivani Karna, there are many options here. Here are two approaches I would consider:
open a file a context manager to write to and write each found element on a new line:
https://www.w3schools.com/python/python_file_write.asp
parse the elements into a dictionary and then write the contents to a pandas dataframe, then to a csv file for a readable format:
https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.to_csv.html
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
This should be pretty straight forward, but I haven't been able to find anything in the documentation.
How can I open an excel workbook and clear all data on a specific sheet, and then write the data in a pandas DataFrame to A1 of that sheet?
Thanks!
Easiest and safest, delete and recreate
workbook.remove_sheet(sheet_name)
df1.to_excel("file_name", sheet_name=sheet_name)
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I have one excel file with 20 sheets in python. for using leave one out technology I have to add all sheets to one sheet.
How can I use a loop in python for doing this.
I'll recommend you to use Python library, which is called Pandas for this task.
You may find nice guide how to do it here
Hope, it will be useful.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
Hi my project works on Django Python. What I want to achieve is since django tasty pie doesn't support combining two resources(no relationship b/w the tables), I need to come up with my own resource. Here I have 2 tables, Table A and B. There is no relationship b/w these 2 tables. But both the tables have a field/column named gname in common. So I want to get all the distinct gnames from both the tables and put it into one list (no duplicated values) and I need to display these gnames as a list in my template. Is there anyway to do that? Thanks in advance.
try:
gnames1 = list(A.objects.values_list('gname',flat=True).distinct())
gnames2 = list(B.objects.values_list('gname',flat=True).distinct())
gnames = list(set(gnames1+gnames2))
render(request, 'sampletemplate.html', {'gnames':gnames})
Set is a data structure that doesn't allow duplicate values.
You can add all the values from both the tables to it and I think you are good to go.
Python Sets
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
prettytable.PrettyTable can represent tabular data in visually appealing formatted tables, and print these tables to the terminal.
How do I save a table as a text file?
According to the tutorial section on ASCII tables, you can get the table output as a string:
table = ... # code for creating table goes here
table_txt = table.get_string()
with open('output.txt','w') as file:
file.write(table_txt)