How to get Output from this Program into Excel?

In summary, to get output from this program into Excel, you will need to first save the program's output as a .csv file. Then, open Excel and import the .csv file into a new workbook. This will allow you to view and manipulate the program's output data in Excel. Additionally, you may need to adjust the settings in Excel to properly format the data. Once imported, you can use Excel's features to analyze and visualize the data from the program.
  • #1
WWGD
Science Advisor
Gold Member
7,372
11,336
Hi All,
I have been trying to teach myself programming recently (Python, mostly). I obviously still have a good way to go. User MarneMath was nice-enough to help me in this post a while back:
:
https://www.physicsforums.com/threads/classification-valuation-problem-baseball.893418/#post-5630986

on scraping data using Python. Now, I ran it in Anaconda and it did compile. I made a small change to it , changing "somefilename" to "somefilename.csv" . Now, this may be very simple, but, what do I need to do in order to get an Excel file with the .csv format? I know the program created a file, but I am not sure how to export it into an Excel file. Any ideas?
Thanks.
 
Technology news on Phys.org
  • #2
It depends on which version of Excel.
Open a blank worksheet. Select 'Data' (from the ribbon), 'From Text', then select the desired CSV file.

There was something about Excel's CSV import in later versions that infuriated me, can't recall what, and in my opinion OpenOffice and LibreOffice do a better job of it.
 
  • Like
Likes WWGD
  • #3
Asymptotic said:
It depends on which version of Excel.
Open a blank worksheet. Select 'Data' (from the ribbon), 'From Text', then select the desired CSV file.

There was something about Excel's CSV import in later versions that infuriated me, can't recall what, and in my opinion OpenOffice and LibreOffice do a better job of it.
Sorry, if this is dumb but how is Excel aware of the existence of the file, if the program , run in Anaconda, makes no mention of Excel? Will it recognize it by the name alone? EDIT: Never mind, thanks, Asymptotic.
 
  • #4
WWGD said:
Sorry, if this is dumb but how is Excel aware of the existence of the file, if the program , run in Anaconda, makes no mention of Excel? Will it recognize it by the name alone?

Let's see if I'm thinking about this correctly.
You have created a CSV data file with the Python program, and want to load it into Excel.
In that case, run Excel, and import the CSV as described above. If you want to end up with an XLS formatted file, then save it in that format.

... or do you want the Python program create an XLS file directly?
 
  • Like
Likes WWGD
  • #5
Asymptotic said:
Let's see if I'm thinking about this correctly.
You have created a CSV data file with the Python program, and want to load it into Excel.
In that case, run Excel, and import the CSV as described above. If you want to end up with an XLS formatted file, then save it in that format.

... or do you want the Python program create an XLS file directly?
The first is the case, thanks. Yes, I realized the import function would do it. Would Excel be able to do it directly without using Python, i.e., could I import an .html into Excel and save it as a .csv?
 
  • #6
WWGD said:
The first is the case, thanks. Yes, I realized the import function would do it. Would Excel be able to do it directly without using Python, i.e., could I import an .html into Excel and save it as a .csv?

I don't think so, if you are using Python to scrape data from a web page then writing it into columns within the CSV file.
 
  • Like
Likes WWGD
  • #7
Asymptotic said:
I don't think so, if you are using Python to scrape data from a web page then writing it into columns within the CSV file.
Excellent, thanks for everything.
 
  • #8
@WWGD, I'm not sure from your posts if you realize that CSV stands for Comma Separated Values. As long as that is what you put in the file, Excel can natively read files with a .csv extension. Note that if the data in an individual cell has a comma in it, you need to surround that data with quotes. Excel will understand that as well.
 
  • Like
Likes harborsparrow and WWGD
  • #9
WWGD said:
Hi All,
I have been trying to teach myself programming recently (Python, mostly). I obviously still have a good way to go. User MarneMath was nice-enough to help me in this post a while back:
:
https://www.physicsforums.com/threads/classification-valuation-problem-baseball.893418/#post-5630986

on scraping data using Python. Now, I ran it in Anaconda and it did compile. I made a small change to it , changing "somefilename" to "somefilename.csv" . Now, this may be very simple, but, what do I need to do in order to get an Excel file with the .csv format? I know the program created a file, but I am not sure how to export it into an Excel file. Any ideas?
Thanks.
I have directed Excel from a Visual Basic program. I have never tried it with Python - but here's a website that describes that:
http://pythonexcels.com/python-excel-mini-cookbook/
You should be able to bypass the csv file altogether - going directly to the *.xls or *.xlsx..
 
  • Like
Likes WWGD
  • #10
Excel allows the csv file to be imported as text through the wizard. In the wizard there are choices for how the data is delimitated. Select comma delimited and answer the questions as you click next within the wizard. Hope that helps
 
  • Like
Likes WWGD
  • #11
WWGD said:
Hi All,
I have been trying to teach myself programming recently (Python, mostly). I obviously still have a good way to go. User MarneMath was nice-enough to help me in this post a while back:
:
https://www.physicsforums.com/threads/classification-valuation-problem-baseball.893418/#post-5630986

on scraping data using Python. Now, I ran it in Anaconda and it did compile. I made a small change to it , changing "somefilename" to "somefilename.csv" . Now, this may be very simple, but, what do I need to do in order to get an Excel file with the .csv format? I know the program created a file, but I am not sure how to export it into an Excel file. Any ideas?
Thanks.
Click on the file to open it in Excel. In the menus select Save As...
and save the file. That's all.
 
  • #12
harborsparrow said:
Click on the file to open it in Excel. In the menus select Save As...
and save the file. That's all.
Thanks, but the file is not created " explicitly" that I can tell; what I did was just to use the import wizard.
 
  • #13
WWGD said:
Thanks, but the file is not created " explicitly" that I can tell; what I did was just to use the import wizard.

It seems I don't understand your question. Are you using office automation to animate Excel to do something?
 
  • #14
harborsparrow said:
It seems I don't understand your question. Are you using office automation to animate Excel to do something?
No sorry, I think I am a bit confused myself, as a beginner in this general area. I am using Python to scrape data from a site and then store it in Excel. I ultimately want to stream data continuously from the website into cell phones, but this was just a practice step, to get my hands wet. Sorry for the confusion.
 
  • #15
WWGD said:
No sorry, I think I am a bit confused myself, as a beginner in this general area. I am using Python to scrape data from a site and then store it in Excel. I ultimately want to stream data continuously from the website into cell phones, but this was just a practice step, to get my hands wet. Sorry for the confusion.

In general I'd suggest taking a look at Pandas dataframes module for Python, when you're ready. (Basically excel spreadsheets inside python.)

In the mean time you may want to check out "Automate the Boring Stuff", in particular, chapter 12 is about interfacing python and excel, and chapter 16 has stuff on automating text messages and emails, which is only slightly lower tech than what I think you're aiming for. (There's also chapters on reading and writing to files in general and web scraping and other stuff.)

In any case the book is made freely available by the author here:

https://automatetheboringstuff.com/

all Python and explicitly targets people new to programming
 
  • Like
Likes WWGD
  • #16
Is this question simply that you want to write the file to an excel?

df.to_excel("something.xlsx")
 
  • #17
MarneMath said:
Is this question simply that you want to write the file to an excel?

df.to_excel("something.xlsx")
Yes, in part, and also general ideas/methods on scraping data how-to's.
 

FAQ: How to get Output from this Program into Excel?

How can I export the output from a program into Excel?

To export the output from a program into Excel, you can use a built-in function or library that allows you to save the output as a CSV (Comma Separated Values) file. This file can be opened and edited in Excel.

Can I customize the formatting of the output in Excel?

Yes, you can customize the formatting of the output in Excel by using formatting options such as changing the font, adding borders, and applying conditional formatting. You can also use Excel formulas to manipulate the data in the output.

Is there a way to automate the process of exporting the output to Excel?

Yes, you can automate the process of exporting the output to Excel by using scripting languages such as Python or VBA (Visual Basic for Applications). These languages allow you to write code that will automatically save the output as an Excel file.

Can I export multiple outputs from different programs into one Excel file?

Yes, you can export multiple outputs from different programs into one Excel file by using the "Import Data" feature in Excel. This feature allows you to import data from different sources and combine them into one file.

Is there a limit to the amount of data that can be exported into Excel?

The limit for the amount of data that can be exported into Excel depends on the version of Excel you are using and the capabilities of your computer. However, there are ways to optimize the process and handle larger amounts of data, such as using a server or database to store the data and then importing it into Excel.

Similar threads

Replies
8
Views
2K
Replies
8
Views
1K
Replies
6
Views
3K
Replies
34
Views
3K
Replies
7
Views
7K
Replies
4
Views
4K
Replies
6
Views
5K
Back
Top