Jump to content

Export mysql table as csv for msexcel


giunz

Recommended Posts

Hello everyone.

I want to export the data of a table as csv.The problem is that the table contains greek characters and when I try to export them with php in a csv file, the output file displays the greek chars as ? even in the notepad.The webpage charset is set to utf8,the same as the db's (utf8_bin).

 

The sql export of the table i need to export in csv this one:

-- phpMyAdmin SQL Dump

-- version 3.1.1

-- http://www.phpmyadmin.net

--

-- Host: localhost

-- Generation Time: May 25, 2009 at 11:17 AM

-- Server version: 5.1.30

-- PHP Version: 5.2.8

 

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";

 

 

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;

/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;

/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;

/*!40101 SET NAMES utf8 */;

 

--

-- Database: `unipi`

--

 

-- --------------------------------------------------------

 

--

-- Table structure for table `contact`

--

 

CREATE TABLE IF NOT EXISTS `contact` (

  `contactId` bigint(255) NOT NULL AUTO_INCREMENT,

  `contactName` varchar(255) COLLATE utf8_bin NOT NULL,

  `contactSurname` varchar(255) COLLATE utf8_bin NOT NULL,

  `contactPhone` varchar(255) COLLATE utf8_bin NOT NULL,

  `contactEmail` varchar(255) COLLATE utf8_bin NOT NULL,

  `contactTitle` varchar(255) COLLATE utf8_bin NOT NULL,

  `contactOrgId` bigint(255) NOT NULL,

  PRIMARY KEY (`contactId`)

) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_bin ROW_FORMAT=DYNAMIC AUTO_INCREMENT=4 ;

 

--

-- Dumping data for table `contact`

--

 

INSERT INTO `contact` (`contactId`, `contactName`, `contactSurname`, `contactPhone`, `contactEmail`, `contactTitle`, `contactOrgId`) VALUES

(1, 'Σοφοκλης', 'Σοφοκλεους', '210666666', 'afentiko@palati.gr', 'Κος', 1),

(2, 'Νικος', 'Νικολαου', '2106666666', 'nikolaou@nikos.com', 'Κος', 2),

(3, 'Δειγμας', 'Παρασκευάς', '2109999999', 'example@example.com', 'Mr', 3);

 

I have also added the php which has the export code similar to :  http://www.phpsimple.net/tutorials/mysql_to_csv/

 

Thank you

 

[attachment deleted by admin]

Link to comment
Share on other sites

the data is in 2byte format for special characters. notepad reads one byte characters, unless you file-saveas and click encding type as utf8. Have you tried putting it into excel and seeing what happens? I think when you save the csv file as UTF8 the headers in the file will be recoognized by excel then it will work.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.