[Tutor] Questions

George Fischhof george at fischhof.hu
Mon Apr 8 13:33:20 EDT 2019


Diana Katz <diana.katz at gmail.com> ezt írta (időpont: 2019. ápr. 7., V,
10:01):

> 1) Can you use python from excel? Or just export to excel?
> 2) I am trying to see if there's a way using python to automate all of this
> work that I need to do. I have to collect quarterly segment data for
> hundreds of public companies and go back at least 12-16 quarters. We use an
> aggregator like factset and they actually don't have this option available
> in an automated way. So I'm trying to see if there's a way to build this.
> Basically, I get my data from sec.gov and they have interactive data -
> they
> even have the data in excel (though it's a messy file and hard to read). I
> attached some of the steps and the data that i'd want to see.
> Basically i'd want the excel to look like:
> old to new quarters - going back 12 to 16 quarters (more if possible but
> not if it will stop the project).
>  Columns: 3/31/2017, 6/30/2017, 9/30/17, 12/31/17, 3/313/2018...
> Rows:
> Sales for segment A
> Sales for Segment b
> Sales for SEgment C
> …(for as many segments as they have)
>
> Earnings for Segment A
> .Earnings for Segment B
>
> Depreciation for Segment A
> Depreciation for Segment B
> Depreciation for Segment C...
>
> I included where I get the data in the attached document.
>
> All the best,
>
> Diana Katz
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor



Hi Diana,

you can write excel addins in Python with this program:
https://www.pyxll.com/index.html

and you can use excel from Python too.
The two ways:

- If you do not need the excel process itself (it means that you do not
want to recalculate for example, or do any calculation, then perhaps
openpyxl would be a great choice for you:
https://pypi.org/project/openpyxl/
there are some templates and other stuff as well:
https://pypi.org/search/?q=openpyxl

- the other way is, when you want to  do calculations, then xlwings is your
package:
https://pypi.org/project/xlwings/
it uses win32com API, there are some edge cases where it does not allow you
to access low level com API functions. I faced with this, and created an
excel helper over win32com API instead of using xlwings, but I do not think
you will need that. (If yes, then code of xlwings can help you


BR,
__george__


More information about the Tutor mailing list