Python Forum
How can I copy and paste data from text file into an Excel sheet?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How can I copy and paste data from text file into an Excel sheet?
#1
I am trying to automate a process that basically reads in values from text files into certain excel cells. I have a template in excel that will read data from various sheets under certain names. For example, the template will read in data from "Video scores". Video scores is a .txt file that I copy and paste into excel. There are 5 different text files used in each project so it gets tedious after a while and when there are a lot of projects to complete.

How can I import or copy and paste these .txt files into excel to a specified sheet? I have been using openpyxl for the other parts of this project, but I am open to using another library if it can't be done with openpxl.

I've also tried opening and reading a file, but I couldn't figure out how to do what I want with that either. I have found a list of all the files I need, its just a matter of getting them into excel.

Here is a sample of the .txt file: https://pastebin.com/FUvH6TbM

One thing I have tried to do is user pyperclip to open and copy the text file. I have that saved to a variable, so if I could somehow open excel and hit "paste" it would format fine.

If I were to manually copy all of the .txt file and paste it directly into excel, it would format absolutely perfectly. I just dont know how I can do this with Python.

Thanks in advance for anyone who helps.
Reply


Messages In This Thread
How can I copy and paste data from text file into an Excel sheet? - by IrishOrigi - Mar-18-2020, 04:37 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Why is the copy method name in python list copy and not `__copy__`? YouHoGeon 2 307 Apr-04-2024, 01:18 AM
Last Post: YouHoGeon
  Python openyxl not updating Excel file MrBean12 1 370 Mar-03-2024, 12:16 AM
Last Post: MrBean12
  Copy Paste excel files based on the first letters of the file name Viento 2 476 Feb-07-2024, 12:24 PM
Last Post: Viento
  What script to paste folders thenewcoder 1 686 Nov-29-2023, 09:40 AM
Last Post: Pedroski55
  Search Excel File with a list of values huzzug 4 1,291 Nov-03-2023, 05:35 PM
Last Post: huzzug
  Updating sharepoint excel file odd results cubangt 1 893 Nov-03-2023, 05:13 PM
Last Post: noisefloor
  How to copy work sheet data one workbook to other? sayyedkamran 2 724 Nov-03-2023, 09:10 AM
Last Post: Larz60+
  Python and pandas: Aggregate lines form Excel sheet Glyxbringer 12 1,967 Oct-31-2023, 10:21 AM
Last Post: Pedroski55
  Copy data from Excel and paste into Discord (Midjourney) Joe_Wright 4 2,130 Jun-06-2023, 05:49 PM
Last Post: rajeshgk
  Reading data from excel file –> process it >>then write to another excel output file Jennifer_Jone 0 1,139 Mar-14-2023, 07:59 PM
Last Post: Jennifer_Jone

Forum Jump:

User Panel Messages

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