My python code was to append one row at a time of multi-column data into a text file, which i then needed to pull apart column-by-column.. not row by row. It looks like a normal text document with elements split by spaces, meaning:
0.00000 107.07925 25.34190 -1.22487 0.63152
1.00000 88.51627 6.54154 -1.27440 0.90064
2.00000 76.58229 3.43457 -1.14756 0.88143
So on so forth. When i open the notepad file, that is what it looks like. But it copies-and-pastes weird...
0.00000
107.07925
25.34190
-1.22487
0.63152
1.00000
88.51627
6.54154
-1.27440
0.90064
2.00000
76.58229
3.43457
-1.14756
0.88143
And i have gone through all combinations of replacing all spaces with semicolons, ampersands, and even copy-and-pasting the amount of spaces a tab creates just in the effort of getting this to import into Excel..
Can anyone help me figure out what causes this issue and how to fix it? Thank you.
As for opening it in Excel since it is split by spaces you might try changing the text to columns option setting to be space instead of the default tab. This option is listed under the data tab(Excel 2013). As far as I know the easiest way to do this would be to open a blank excel sheet type anything into A1 and then click the text to columns button. Select delimited and then Next change the options on this page to space instead of tab then finish. Now delete whatever you typed into Excel. You can copy and paste the data into this excel window now and it should work for you. Now this setting will reset when you close and reopen excel.
Related
Disclaimer - this should be a very simple task, but clearly everything I thought I knew about excel is false.
I'm trying to copy and paste data from a txt document to an excel document. An example of a line I'm trying to copy from the txt doc is: 4512544425701264.
However, when I paste into excel it pastes as 4512544425701260 but displays in the cell as 4.51254E+15. This happens for each line of data.
I've tried numerous ways to fix this problem none have worked including:
Copied the txt data into a Microsoft Word document, then tried
pasting into the excel.
Resized the cell.
Tried each cell formatting option.
Tried opening the txt doc in Excel, even progressed through the text import wizard. Interestingly, I noticed the data preview on page 3 displayed the data correctly. But after proceeding past the importer, the data loaded with the same problem.
Tried on another PC.
Copied and pasting one line at a time.
The only solution I have found is manually typing out each line, however this is highly unpractical due to the large amount of data.
Any help/advice would be greatly appreciated.
To show full number rightclick on cell, choose "Format cells..". In "Number" tab choose "Number" category and set "Decimal places" to zero.
Unfortunately excel lets to put only 15 digits as a number. Every additional number is converted to 0, that is why your number 4512544425701264 is converted to 4512544425701260
If you don't need this number to be used in calculation, you can format cells to text format before pasting:
Source on digits limitation: https://learn.microsoft.com/en-US/office/troubleshoot/excel/last-digits-changed-to-zeros
In Excel, this is expected behavior (it's Microsoft, after all). I have encountered it frequently when dealing with UPC codes, for example. In order to avoid this, format the cells you are trying to copy this data to as "Text" BEFORE you copy any data over.
Copy your data (CTRL+C), then select the first cell in the range where the data is going, then paste only the values. This should take care of it.
If for some reason you still get scientific notation, provided the cells have the "Text" formatting, you can select that cell, click in the Formula bar and hit ENTER.
When you paste into Excel, try calling "Text import wizard" in the Paste Options. This will allow you to set delimiter (in case of CSV) and later data type of a column where you can select "Text" which will tell wizard not try to convert your data into numbers.
I have a csv file below:
RTC ID,RTC Type,RTC URL,ADS URL,RTC Unreachable Children,# RTC Unreachable Children
199420,story,https:/xxx890,httxxxxxxxxx9420,"199701,199858,199608",3
If I preview it in vscode, it looks fine, but when opened in excel, the "RTC Unreachable Children" column is displaying incorrectly.
I've tried clicking to highlight the entire column and changing the text formatting in excel but string / general / dont work, is there any way I can tell excel to display the commas separating each number inside the quotation marks?
This worked, i had to go through these steps:
open new excel
go to 'data' tab, import from csv
choose csv
choose 'transform data' before importing
go to the column and select it
go to data type and set as 'text'
import csv
save as .xlsx or something else (dont save as .csv)
done
Thank you #POVR2 and #ScottCraner in the comments
I have an excel File filled with data which often doesn't fit in one line. Obviously these lines are getting split into two. Working as intended so far. But sometimes Excel decides there is a need for a line break even tough the text does fit on one line.
My guess would be that Excel sets a margin for its cells, but how can I modify it to prevent this from happening?
WordWrap a.k.a. Wrap Text is your friend:
Here you can see more.
If you are copy pasting.
Paste the desired object within the box with the blinking cursor (Easy).
This will paste the contents only within a block.
if the documents from which you are copying the content consists of line breaks for new paragraphs then excel takes those line breaks as new rows/columns.
for your problems if your document has made split cells for the content, Try
Selecting the columns you wish to combine together.
then use the formula.
=CONCAT(CELL A,CELL B)
Hope this helps you.
Now this is a weird one
We have a project where we are reading some data from an Excel spreadsheet. Obviously this data has to be in a certain format. Some of the fields consists of numbers, but should be treated as text.
To stop Excel from being "smart" and change the cell types, I have set the format in the respective cells to 'text'.
Now here is the problem: some of the numbers we're pasting have spacing between the digits. When we remove the white spaces, Excel change the cell format to 'standard' and turn the text into the 2.42805E+11 format.
BUT: this only happens when the text is copied from some sources. If a paste a number copied from a textbox, everything turn out fine when we edit the spaces. If we copy the exact same number from a web page, Excel change cell format.
I thought copy-paste would be copy-paste, but obviously some formating or something gets along on the ride.
Does anyone know what causes this, or know have to get Excel to stop being "smart" with the formating?
EDIT: I found a somewhat peculiar solution to this. I recorded a macro that uses the 'Paste Special' function with text as parameter, and overrided ctrl-v with it (in that particular spreadsheet). Works like a charm! Feels a bit "hacky", though. Can anyone think of a scenario where this will backfire?
Try using the Edit Paste Special command, it will give you some controls to choose what to do with the data.
For a taste of the complexity of what is really going on underneath, look in MSDN about Clipboard Formats. In short, it isn't all Excel's fault...
A common user trick copying data out of excel is to paste it into Notepad and cut it back to the clipboard, which flattens all the formatting down to plain text. It won't help you for pasting data into Excel, however.
Copy-paste in windows retains formatting. One way to get rid of the formatting is to paste the text into e.g. notepad first, then select and copy it again. This loses any copied formatting.
I have a plain text file looking like this:
"some
text
containing
line
breaks"
I'm trying to talk excel 2004 (Mac, v.11.5) into opening this file correctly. I'd expect to see only one cell (A1) containing all of the above (without the quotes)...
But alas, I can't make it happen, because Excel seems to insist on using the CR's as row delimiters, even if I set the text qualifier to double quote. I was sort of hoping that Excel would understand that those line breaks are part of the value - they are embedded in double quotes which should qualify them as part of the value. So my Excel sheet has 5 rows, which is not what I want.
I also tried this Applescript to no avail:
tell application "Microsoft Excel"
activate
open text file filename ¬
"Users:maximiliantyrtania:Desktop:linebreaks" data type delimited ¬
text qualifier text qualifier double quote ¬
field info {{1, text format}} ¬
origin Macintosh with tab
end tell
If I could tell Excel to use a row delimiter other than CR (or LF), well, I'd be a happy camper, but excel seems to allow the change of the field delimiter only, not the row delimiter.
Any pointers?
Thanks,
Max
Excel's open
Looks like I just found the solution myself. I need to save the initial file as ".csv". Excel honors the line breaks properly with CSV files. Opening those via applescript works as well.
Thanks again to those who responded.
Max
The other option is to create a macro to handle the opening. Open the file for input, and then read the text into the worksheet, parsing as you need, using a Range object.
If your file has columns separated by list separators (comma's, but semicolons for some non-English region settings), rename it to .csv and open it in Excel.
If your file has columns separated by TABs, rename it to .tab and open it in Excel.
Importing (instead of opening) a csv or tab file does not seem to understand line feeds in between text delimiters. :-(
Is it just one file? If so, don\'t import it. Just copy paste the content of your text file into the first cell (hit f2, then paste).
If you absolutely must script this, Excel actually uses only one of those two chars (cr, lf) as the row delimiter, but I'm not sure which. Try first stripping out the lf's with an external util (leave the cr's) and then import it... if that does't work, strip out the cr's (leave the lf's) and thenimport it.