Exporting .xls to .csv issues - excel

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. :-)

Related

funny format when copy from CSV

I used python to write some text to csv but it is stored in funny format.
output data is saved here:example data
for example, it is read as the below in csv excel
text shown in CSV
when i copy it to other platforms(notepad, word, web application) it turns into something else
after copy
I tried a numerous method include formatting with the CSV but it just wont work.
Could someone please help me.
With thanks,
Iverson
It's hard to guess what you mean...
Your file has TABs between many characters. But every line starts and ends in a double quote ("). So the whole line is one value (cell).

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.

writing csv to open as different tabs in Excel

Is there some way to write a csv file such that , when opened in MS Excel , it will open in different tabs in the workspace ?
The short answer is, NO.
For that matter, the long answer is NO too.
csv is a continuous run of lines of values separated by commas. each line doesn't even have to have the same number of values etc. there's no concept of workbooks or different "areas" in csv. Excel cannot be cajoled into opening a csv into multiple workbooks...well at least not without writing VBA to parse the csv file yourself.
the oxml or whatever they've ended up calling the xml file spec for office, allows workbooks and is still easy to deal with being text based. Do you have to use csv or can you switch (at least part way through) to xml?

Opening tab-delimited text file in Excel mangles special symbols

I have a tab-delimited text file which contains dagger characters (†). When I open this in Excel 2010, they are mangled and replaced with † (I'm not sure if Excel is adding the space, too). Why does this occur and how can I fix it?
Right now I do search and replacing in Excel to replace the †s, but it's inefficient for many files and hacky.
The original file is not using the character encoding that Excel expects.
See
Character Encoding and the ’ Issue
Excel's Import Wizard is better at handling encoding issues and may be able to open your source file properly. See
Microsoft Excel mangles Diacritics in .csv files?
Nevermind, after taking another look at Open .csv file containing special characters in Excel I realized that instead of Right Click -> Open with Excel, if I go to File -> Open in Excel it lets me choose the encoding.

Excel and Tab Delimited Files Question

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.

Resources