Ask Your Question
0

pasting spreadsheet data without linefeed at end

asked 2015-02-10 16:03:04 +0200

dwlamb gravatar image

Is there a method to paste spreadsheet data so there is no carriage return or line-feed at the end of the string?

I have tried using SUBSTITUTE and TRIM to no avail. I really need a method so the copied data is clean when pasted in an application or a little symbol appears signifying an uninterpreted character(s) is/are present

edit retag flag offensive close merge delete

3 Answers

Sort by » oldest newest most voted
0

answered 2015-02-11 02:06:09 +0200

karolus gravatar image

updated 2015-02-11 02:16:36 +0200

With python and installed 3rd-party-modul pyperclip →→....pip3 install pyperclip --user

import pyperclip as clipboard
newstring = clipboard.paste().strip()

# maybe do something more here with newstring
# eg: newstring = newstring.replace('\n', '\t')

clipboard.copy(newstring)
edit flag offensive delete link more
0

answered 2015-02-10 21:03:29 +0200

dwlamb gravatar image

I do not want to paste into a cell or anywhere in LibreOffice. I want to paste from my spreadsheet into another application where paste special is not available.

edit flag offensive delete link more

Comments

Suppose you are working on Windows. A 'Copy/Paste' of contents from one application into another one has to use the clipboard. LibreOffice neither knowing the capabilities of the target application nor having full power over the clipboard cannot offer what you want, I think.

Lupp gravatar imageLupp ( 2015-02-10 23:03:10 +0200 )edit
0

answered 2015-02-10 16:35:17 +0200

Lupp gravatar image

updated 2015-02-10 23:23:26 +0200

What's spreadsheet data?

Copied from multiple cells, you will always get a new paragraph shifting from one cell to the next one. Copying from one cell and inserting by 'Paste Special' as 'unformatted text' you will not get a NewParagraph inserted.

==== Editing with regard to the questioner's comments. ==== Any application accepting text from the clipboard will have to insert it on its own responsibility. LibreOffice cannot even prevent a substitution of any "u" by an "x" if the accepting software is programmed to do that.

If you want no (or as few as possible) line breaks (may also be NewParagraph) you first must prevent Calc from exporting them. To achieve this you should assemble the content of as many cells as possible by formulae, suppressing internal LineFeeds and simply inserting a space between the contents of two subsequent cells. This can never be done for more than 65536 characters at a time which is the maximum a single cell can contain. As Calc does not offer a range concatenation, more detailed advice will depend on the details of the task (How many cells, how much text per cell and in total ...).

Hope someone else has better ideas.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2015-02-10 16:03:04 +0200

Seen: 742 times

Last updated: Feb 11 '15