I am trying to OPEN .txt-file in Excel. The values should be numeric but instead are shown as dates! When manually converting "date columns" to "general" or "numeric", the number is not shown correctly.
Eg. the value should be 1.71942 -- it is shown as date 1.7.1942 --- when manually changing the format --> 15523.
This is what I found:
"If there is a recognizible date in the data, the cell will be formatted as a date in the worksheet even if the setting for the column is General. "
The question is: how to best avoid this problem and open the data in the right form? I really appreciate any advice!
According to Microsoft:
Unfortunately there is no way to turn this off. But there are ways to
get around it.
If you can change the content of the text file before opening it into Excel, there are several ways. For example, you could insert an apostrophe ' before the number. See this other post on Stack Overflow too.
Related
I have a column of time durations in an Excel sheet that is destroying my week. I wish I could make a custom hhh:mm format for this column, but I am only allowed to edit this sensitive document on SharePoint and Sharepoint does not support custom formats. Consequently, this is the best I can do for time duration:
Works fine. Most of the rows use this format. But inexplicably, many of the rows have this format instead:
This format difference messes with formulas, and as you can you see in the picture the time "duration" is different in the formula box. The time as it appears on the sheet is correct This format resists all attempts at change, and I've looked up quite a few solutions. Reformatting the whole column has no effect. Copy pasting the values in various ways either retains the problem or produces incorrect results. The Text to Columns fix I've read about in a few places gives me the time as it appears in the formula bar, not the (correct) time as it appears in the sheet.
I am extremely desperate for a fix. I appreciate whatever help you can provide. Please keep in mind that I cannot use custom formats on Sharepoint and I cannot edit this document elsewhere.
I collect various data in time plots. If I copy the timeplot data and then paste it into Excel, the number format is often wrong. For example, I often get a date like Aug 94 instead of the actual number from the TimePlot. Unfortunately, I can't easily format this date into a number either, since the formatted number does not match the actual number from the timeplot. If I format the date in the same format as the number above and below, then I get the number 34547. However, this number does not correspond to the actual number of the TimePlot. Anyone know how I can prevent this problem?
You can only solve this on the Excel side, AnyLogic provides the raw data for you. Excel then interprets stuff. You can test it by pasting the chart raw data into a txt or csv file.
So either fix your Excel settings or paste into a csv, then into an xlsx.
Or better still: Do not manually paste at all. Instead, write your model results into the AnyLogic database and export to Excel from there: this takes away a lot of the pain for you. Check the example models to learn how to do that.
This is not AnyLogic question, rather an Excel & computer formatting problem. One way of resolving this is changing computer's date and time settings.
Another way is to save your output at txt file in AnyLogic. Replace all . with ,. Then open empty Excel, select Text format for the columns. Copy-paste from the txt file.
In Excel there are a few options
when you paste use paste as text only option
But this does not always work as Excel will still try to format the stuff for you
Use the Paste Special option and then choose text
Also possible this will not work, based on your Excel settings.
Paste using the text import wizard
(This works for me without fail)
On step 2 choose tab delimited
On step 3 choose Column format as text for every column (you need to select them in the little diagram below)
You will then see the data exactly as it came from AnyLogic. See the example below where I purposefully imported some text which has something that Excel will think is a date. You will now be able to see what in your data made Excel thing your data needed to be formatted the way it is and then you can fix it. (post a new question if you struggle with this conversion)
But as noted by other answers first prize is to write all the important data to external files. But I know that even I sometimes want to export data from a chart and review it in Excel. Option 3 works for me everytime
I am struggling with the different cell formatting types in Libre Office - I am aware of the manually adjustable Date formatting, but cant get Libre Office to recognise an input text string like:
" Wednesday, December 11, 2013 13:27"
where everything between the quotes is the cell content. Obviously I want the software to recognize, that this is a date and thus make a graph out of a large table, but using a manual formatter like:
" NNNN, MMMM D, YYYY HH:MM"
does not result in what I want, ie. the cell accepts my manual format but still cant cope with the content. What am I doing wrong? - any tips how I can nevertheless produce a graph with x-values with dates in this format? I dont want to awk around and manually convert these strings each time I have such a table...
Thanks a lot!
Be aware that during the import process you have a chance to set the date format during this import routine in Librecalc. Find this and use it.
I found that the fix must come while opening a CSV file to avoid being down the rabbit hole of errors and frustrations.
The preview of data on open is interactive. Who knew? :o
Do this:
Open
Select columns with dates in the preview
Change setting from Standard to Date in the dropdown
I have a file (only one) with some columns with integer numbers. When I change and save file, those columns are automaticaly converted in dates. Does anyone knows how can i prevent this? Thank You!
you might want to check out a similar issue here:
http://www.mrexcel.com/forum/excel-questions/637277-excel-converting-numbers-dates.html
(the below suggestions might not be particularly relevant to this issue, but in general, they might help to resolve such a problem)
Selct the cells and go to Format --> cells --> number and select Text for the selection
There's also a one-keystroke solution: type an apostrophe before entering or pasting a pair of numbers that Excel could mistake for a date and month. When you exit the cell, the apostrophe vanishes and the numbers stay numbers, formatted as text.
this is what microsoft says:
http://office.microsoft.com/en-001/excel-help/stop-automatically-changing-numbers-to-dates-HA102809473.aspx
also if you are pasting data from somewhere else
try Paste Special
I guess there is still no solutions to this problem.
It happens in both my computers when inserting data from sql server 2008.
Half of columns becomes dates..... and im supposed to give this to my accountant.. sucks
(Btw i know about the special paste to text, then convert to number... but it takes so much time)....
I just ran into this issue. I am using a webhook to store data to excel on the fly, adding new rows, updating existing data, etc.
I had a special field "step" which is a string who can be "1", "1.1", "1.2", etc. which was treated as date as soon as the value was a "string decimal"...
The only way I could find to fix this issue was to programmatically add a ' before the value, like '1.2.
I tried to apply this to all my fields to avoid excel side effect, but I then noticed that when updating an existing row by merging new values with existing values then the ' was stripped. So, I end up using a whitelist of fields to escape. I couldn't locate the fields to force adding ' when merging data due to limitations from the lib I use google-sheets-node-api.
I run a process to produce a rather large CSV file of data. Sometimes I find it helpful to open the CSV in excel, make changes manually, and then re-save. However, if there are dates in the CSV, excel automatically reformats them. Is there a way to prevent excel from doing this? It would be helpful if I could turn off all text formatting altogether.
If you prepend an apostrophe ' to the beginning of any date string during the export process, Excel will read the value literally (i.e. as plain text) rather than trying to convert it to a date.
This particular solution is handled during the export process. I'm not sure how you would change Excel to treat the file differently at runtime.
Excel does some nasty tricks when outputting XML. One of its tricks is to drop left most column delimiters if 16 or so consecutive rows have no values for these columns. This means that if you're splitting the lines up based on commmas then these rows will have a different number of columns to the rest.
It will also drop any initial 0's so things like numeric Ids can become messed up.
Another risk you run is chopping the file off short since Excel can only support a maximum number of rows. (Prior to Excel 2007 this was around 65536)
If you need to do anything to a CSV file other than read it use a text editor.
When you import the CSV file into Excel, be sure to pre-format the date column as text. There's a frequently overlooked option in the parsing that allows you to control the format column by column. This also works well for preventing the leading zeros in New England ZIP codes from getting dropped in your contact lists.
If you used the excel file version which is 2010 or later (not sure lower version), you can set up to use current operation-system date format or not in Excel/CSV file.
Right Click cell with date value (e.g. '9/12/2013') in CSV file and pop up the menu
Click 'Format Cells' and open a pop up screen
Go to 'Number' tab and you can see 'Date' was selected in 'Category' (left side) and 'Type' on the right side
Observed that there are two types of Date format (one is with () and another is not with ()). Read the comment there and you can find that you can use the date format which is not with date. It means that your changes to the CSV file will not be applied with your current operation-system date format. So, I think date format won't be changed in CSV file in this case.