-1

so I want to write a python script that when executed will automatically pull certain columns from an excel sheet and automatically import them to something like word.

I am familiar with python, just really bad at it and I have a hard time visualizing how to start...

I'm not asking for a full script, just some examples to nudge me in the right direction and some tips going forward with my project.

Thanks for any help you are willing to offer. Have a great day!

Scott
  • 43
  • 3
  • 1
    Do you really need to work with Excel files or plain and simple CSV would work as well? Anyway.. check https://openpyxl.readthedocs.io/en/stable/ and https://pandas.pydata.org/ – alec_djinn Jul 22 '20 at 12:53
  • 2
    Have you checked the pandas library? You can read the excel sheet using it and then filter out your columns in the script itself before importing it to a word document, if that's what you aim to do. – Suryansu Dash Jul 22 '20 at 12:54
  • CSV would work for my purposes. – Scott Jul 22 '20 at 12:55

1 Answers1

0

Make yourself familiar with library called Pandas. With Pandas you can easily read columns from Excel spreadsheet to a dataframe. You can find Pandas function for that from here: Python Script to Export Data from Excel . Also, using .xlsx for this purpose is not optimal. You could use, for example, .csv format.

You can write Pandas dataframes to .docx file for example this way: Writing a Python Pandas DataFrame to Word document .

Heikura
  • 1,009
  • 3
  • 13
  • 27