Python Forum
Using Pyperclip in Python 3 Does Not Paste Data in Desired Format
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using Pyperclip in Python 3 Does Not Paste Data in Desired Format
#1
I'm using python 3.7 and I want to:
  • Copy IPs from a column in excel
  • Add a comma between each IP separated by a space
  • Return as one line
  • Copy back to clipboard using pyperclip.

Below is the desired pasted results:
10.10.10.10, 10.10.10.11, 10.10.10.12, 10.10.10.13, 10.10.10.14

I have looked at some answers I found here and here but it's not printing the desired results. Below, I have tried the following codes but none seem to do it for me:

#code 1
import pyperclip
text = pyperclip.paste()
lines = text.split('\n')
pyperclip.copy('\n'.join(lines))

#code2
import pyperclip
text = pyperclip.paste()
lines = text.split('\n')
a = '{}'.format(', '.join(lines[:-1]))
pyperclip.copy(''.join(a))

#code3
import pyperclip
text = pyperclip.paste()
lines = text.split('\n')
a = '{}'.format(', '.join(lines[:-1]))
pyperclip.copy(a)
Assistance on providing understanding on what I'm missing and getting the desired results would be appreciated.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  What script to paste folders thenewcoder 1 674 Nov-29-2023, 09:40 AM
Last Post: Pedroski55
  Export data from PDF as tabular format zinho 5 704 Nov-11-2023, 08:23 AM
Last Post: Pedroski55
  Copy data from Excel and paste into Discord (Midjourney) Joe_Wright 4 2,057 Jun-06-2023, 05:49 PM
Last Post: rajeshgk
  How to properly format rows and columns in excel data from parsed .txt blocks jh67 7 1,880 Dec-12-2022, 08:22 PM
Last Post: jh67
  Please help me [copy and paste file from src to dst] midomarc 2 1,017 Nov-24-2022, 10:13 PM
Last Post: midomarc
  Json filter is not capturing desired key/element mrapple2020 1 1,138 Nov-24-2022, 09:22 AM
Last Post: ibreeden
  Issue in changing data format (2 bytes) into a 16 bit data. GiggsB 11 2,664 Jul-25-2022, 03:19 PM
Last Post: deanhystad
  Need Help writing data into Excel format ajitnayak87 8 2,524 Feb-04-2022, 03:00 AM
Last Post: Jeff_t
  how can I display only desired items? 3lnyn0 5 2,038 Dec-25-2021, 06:49 PM
Last Post: menator01
  ImageTk Paste KDog 14 6,943 Jun-27-2021, 11:07 AM
Last Post: KDog

Forum Jump:

User Panel Messages

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