I keep putting a custom format as follows: yyyy-mm-dd
But if i save the file and reopen it goes back to dd-mm-yyyy
It works fine in xlsx, but i need it in csv and if i try converting it from xlsx to csv, same thing happens
Unfortunately there are no style or format settings for CSV file. A CSV file is simply a text seperated by comma or an another delimiter. If you opened up the CSV file in notepad or notepad++ you can see the dates are correctly formatted.
If you want to retain settings, you can try saving it an XML file.
When you open a CSV file directly in Excel, Excel determines the format of the cell based on its interpretation of the text, which is similar to its interpretation of data that enter manually.
Most of the time, the cell format is General. In some cases, it is Short Date, Time, Accounting or Percentage.
Also note that the date or time appearance in the CSV file should be consistent with the Regional and Language Options settings on the computer where the CSV file is opened. Otherwise, Excel interprets it as text.
If you import the file instead of opening it directly, you can control how Excel interprets the data via setting format settings for dates upon import.
Related
I want to save the positive numbers in parentheses in .csv. For example:
My number = (0.235)
When I try to use number format, it automatically converts this number to -0.235. I changed the format, use text format and then it works. However, once I save and re-open the data it again converts to -0.235. I should save it in .csv format. Any advice?
Format -> Cells -> Custom - add new with.. (0);-0.
Then save as normal Excel.
If you save as CSV - then open it in Notepad or TextEdit you will see the parentheses and minus sign are saved.
But when re-opening it in Excel it reconverts it back to -1/1 etc losing your parentheses.
Best to use Excel format when saving to preserve the formatting options.
The problem is not when you save it in CSV (assuming you converted to text format as you mention above; or use a custom number format like that shown by #JGFMK). The problem is when you open it in Excel.
As is usually the case, in order to prevent Excel from doing automatic conversions, you need to IMPORT the csv file and not OPEN it. You will then have the opportunity to designate that column as TEXT, and your parentheses will be preserved.
When you are dealing with any CSV file, formatting is not included. So Excel tries to interpret the values as best it can (as if you were typing the value into a cell manually). This can cause issues not only with your circumstance, but also with certain fractions, ratios, dates not in the format of the computer system, etc. For all these reasons, you are often best off importing rather than opening any csv file in Excel.
I created a CSV file and I saved it as (CSV UTF8 Comma delimited) but I got message
Some features in your workbook might be lost if you save it as CSV UTF-8 (Comma delimited). Do you want to keep using the format?
I clicked Yes and save the CSV, then I open it again and doing edits when I save it no message appear. but when I open it again the columns merged in one column (as I think the comma removed by somehow!). So what is the issue here??
Before Save
After Save, close, then open it again
NOTE: I'm using Office 2016
Excel has some difficulty understanding how to merge complex codesets (English ASCII and Arabic UTF-8). You have to give it some help. This is not very fun.
We have an exported file csv (the c stands for comma, but really it can be another character)
Open Excel
Select Data - Import External Data - Import Data
Select the file type as csv
select your file
In the Import Wizard change the File origin as 65001 UTF (basically choose the language identifier you need)
Change the Delimiter to comma (or whatever you want to use)
Import
If you are using the save shortcut - use save as instead. I've found it's saving as unicode and you have to switch it to save as a CSV again.
I am working on reports and exporting them to csv files. I have to get the dates in the format YYYYMMDD in the csv files. My problem is that when I open the csv file via notepad or block_notes, I am having the exact format, but, when I open it using MS Excel (which is the tool used by default) I am getting the dates in other format DD/MM/YYYY. I need to force it to be be displayed as YYYYMMDD.
How can I do this?
Thanks in advance
Assuming M_REP_DATE2 contains your date:
SELECT to_char(M_REP_DATE2,"YYYYMMDD")
FROM BM_TRADEATT_REP
If that isn't the case, you'll need to provide some details as to what DT_WSTR and M_REP_DATE2 contain.
I have a .xls I need to convert to .csv
The file contains some date columns. The format on the date is "*14/03/2001" which, according to Excel means the date responds to regional date and time settings specified for the OS.
Opening in Excel you see:
20/01/2013
01/05/2013
Save as... CSV
Open in notepad:
01/20/2013
05/01/2013
I have temporarily fixed by setting date formats to "14/03/2001" (no *) but even some other custom formats with no *, like "d/mm/yyyy h:mm" get mangled when saved to CSV.
Although keeping this in mind http://xkcd.com/1179/
In the end I decided to use the format YYYYMMDD in all CSV files, which doesn't convert to date in Excel, but can be read by all our applications correctly.
You can save your desired date format from Excel to .csv by following this procedure, hopefully an excel guru can refine further and reduce the number of steps:
Create a new column DATE_TMP and set it equal to the =TEXT( oldcolumn, "date-format-arg" ) formula.
For example, in your example if your dates were in column A the value in row 1 for this new column would be:
=TEXT( A1, "dd/mm/yyyy" )
Insert a blank column DATE_NEW next to your existing date column.
Paste the contents of DATE_TMP into DATE_NEW using the "paste as value" option.
Remove DATE_TMP and your existing date column, rename DATE_NEW to your old date column.
Save as csv.
Change the date and time settings for your computer in the "short date" format under calendar settings. This will change the format for everything yyyy-mm-dd or however you want it to display; but remember it will look like that even for files saved on your computer.
At least it works.
You need to do a lot more work than 1. click export 2. Open file.
I think that when the Excel CSV documentation talks about OS and regional settings being interpreted, that means that Excel will do that when it opens the file (which is in their "special" csv format). See this article, "Excel formatting and features are not transferred to other file formats"
Also, Excel is actually storing a number, and converting to a date string only for display. When it exports to CSV, it is converting it to a different date string. If you want that date string to be non-default, you will need to convert your Excel cells to strings before performing your export.
Alternately, you could convert your dates to the number value that Excel is saving. Since that is a time code, it actually will obey OS and regional settings, assuming you import it properly. Notepad will only show you the 10-digit number, though.
If you use a Custom format, rather than one of the pre-selected Date formats, the export to CSV will keep your selected format. Otherwise it defaults back to the US format
Place an apostrophe in front of the date and it should export in the correct format. Just found it out for myself, I found this thread searching for an answer.
A not so scalable fix that I used for this is to copy the data to a plain text editor, convert the cells to text and then copy the data back to the spreadsheet.
Change the date range to "General" format and save the workbook once, and change them back to date format (eg, numberformat = "d/m/yyyy") before save & close the book. savechanges parameter is true.
You can send your date to excel not like the "date" but like just a "string" with empty space at the start and end of the string.
Your problem is happening due to excel see your '11/02/2023' like a date, but you can hack it and change this date to a simple string like ' 11/02/2023 '.
Old: '11/02/2023'
New (solution): ' 11/02/2023 '
I am encountering what I believe to be a strange issue with Excel (in this case, Excel 2007, but maybe also Excel 2003, but don't have access to it as I write this).
I can reliably convert some server data over into a tab-delimited format (been doing this for years) and then open it using Excel - no issue.
However, what seems to be happening is if I have an html <table> inside one of the fields, it looks like Excel 2007 thinks it should be converting the table into rows and columns inside Excel (not what I want). As you might imagine, this throws off the entire spreadsheet.
So question is, is there any way to set up excel to NOT do this (perhaps some setting in Excel that pertains to reading tab delimited files), or am I missing something?
Thanks.
Save your file as .txt
Now open the file in excel using Drag and Drop (rather than double clicking your hookey .xls)
Slightly more work to open the file, but your tab text formatting will now be respected.
When you open the tab-delimited file, you are shown an import mapping dialog that lets you pick each columns' data type (date, text, currency, etc.). For the columns that have HTML data present, choose text. This will tell it basically to import as-is and not try to automatically parse the data into a derived format.
Excel 2003 does the same. I don't think there is a way to do it with a config because Excel finds delimiters in the html table and breaks the html in cells and columns as it does for the other columns.
If the column containing html is always the same, you can use JYelton suggestion of renaming the file as csv and record a small VBA macro to load the file selecting automatically the html column as text in the import mapping dialog and you load the file calling the macro instead of double-clicking on the file.
If nothing else, import it into OpenOffice.org Calc, save as an .xls file, then open in Excel.