how to save a numeric format in csv - excel

my problem is that as soon as I am saving my excel sheet in csv. the content is not seen as numeric anymore. I can't save it. It's a big problem, because when importing the csv. in R, the numbers are mixed up, because the R doesn't recognize the numbers as ascending numbers.

Seems to me there is an option in saving CSV to save the format as the first line. Without that you will have to specify the format each time manually, unless it happens to guess correctly.

Related

Save Positive Numbers in parentheses in csv

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.

Generating file which can Excel easily open and save

i am exporting data from database to file, which can Excel read and save.
(CSV) I generate csv, with default format (according to RFC 4180, comma delimeter). As expected, stupid excel read all data and place it to one cell.
(CSV with semicolon delimeter), this one excel read fine, but after change some value and press save (CTRL+S), stupid excel saved it to unreadable file (well done!). No delimeters, no string separators. Ok, so i tried to save it as (CSV format with SEMICOLON delimeter), saved file looks ok, but after opening it with excel, error message was showed - INCORRECT FORMAT - no cell found :D really?!
Generating .xsl file in php. It take too much RAM (about 2GB), so it cant be used.
Do you know any good format, which can excel easily open and easily save?
Thanks a lot!
This question is off-topic, but IMHO Excel 2002/2003 XML Format would be the best choice in your circumstances.
The reason for this is that the data in this format is typed - so you will not see numbers misinterpreted as dates, or phone numbers with leading zeros stripped. I am not aware of the kind of problems you describe, so I cannot say for sure how those will be affected.

How to export data from spss to excel with out nulls

I have a large data set in SPSS (v20) with null values for some observations.
I tried saving as an excel 2007 file, but when I open excel file "#NULL!" appears in cells where values are null. I'm going out of ram when trying to use 'find and replace' function in Excel.
T tried saving as a csv file then I got a space in the cells where values are null.
Could anybody advice on this please?
I typically save as CSV and then in excel save as .xlsx. All missing values are then, as you noted, allocated a space which I accept as representing sysmis values.
When I work with a file that has been saved directly to Excel, (ie many "#NULL" values), I use a VBA macros which does a find/replace row by row. The macro is quicker than doing it all at once as this typically starts to slow to infuriating speeds. The macro is still not as fast as one would want...which is why I go via CSV.
According to the command syntax reference, #NULL! values occur only for system missing values. So to prevent that you need to assign the system missings a value - for that you can use the RECODE command (e.g. RECODE MyVar (SYSMIS = -9)(ELSE = COPY). would work for a number field in which -9 can not be a valid value).
Depending on what you want the value to be when written to the sheet, you can then use the /CELLS=VALUES subcommand on SAVE TRANSLATE to save the assigned missing numeric category (IMO a bad idea for spreadsheets) or you can assign the missing value a VALUE LABELS and use /CELLS=LABELS to save the string label in the cell.

How do I get my fortran output into excel?

After running a model in fortran (95) I end up with some result arrays (and one result matrix). I'd like to move these into excel for reporting purposes. What's the easiest way to do this?
As S. Lott said before me, CSV format is probably the best choice, but actually Excel is pretty clever about file formats. It will usually work with tab separated or space separated data, or even HTML tables. Try copy-and-pasting your data into Excel to see whether it can work it out, before worrying too much about the format.
Fix your Fortran output to be in CSV format. This is easily imported into a spreadsheet.
You can also write your data into a text file with the below code and then copy paste its contents to excel
before working with these data you must run "paste special wizard" to separate columns of the data in the excel
dimension a(100)
open (25,'output.txt')
do i=1,100
write(25,*) a(i)
end do

Exporting .xls to .csv issues

I have been trying to import this excel file my mysql database, and it has been rough.
There are around 7,000 rows in the .xls file, but when I export it to .csv and parse it with PHP I get one of two issues:
Excel does not escape anything, ie. the commas in each row split the data
When I change all commas to * then export for some reason excel changes a whole bunch of lines to a bunch of pound signs #####.
(Is there a reason it does this?)
I can upload the .xls somewhere if need be.
As a suggestion, if you are dealing with cells that do contain commas which are widespread, an easy solution would be to export from Excel in a Tab-Delimited format (TXT), or yet alone any format that contains a character you would not normally encounter.
I've found it to be a pretty simple way to take care of many of the troubles associated with exporting from Excel and importing into a database medium.
Figured it out!
Turns out it was Excel's fault. I checked the .xls before opening it in Excel, not ###.
But after saving it in Excel they appeared.
So I opened it in Numbers (part of iWork), changed all , to *, and all quotes to % (these never appeared in any line. Exported it to .csv, then changed them back when importing with PHP.
Worked great. :-)

Resources