• Resolved Hydeisch

    (@hydeisch)


    Hi

    I’m not getting the extended asciicharacters as åäöé etc in my CSV file when I export. Can I change that with Utf8_decode for example? (It works only in Notepad).

    In the CSV can I change so I get a column for ticket type without getting the user listed once for every ticket?

    In my example here (http://www.sexetiboras.se/wp/events/spacestation-2013/) they have to buy 1 standard ticket and to that they can add additional activities (Galaxpasset general admission, Caps – a drinking game tournament).

    3	Galaxpasset	Johan Rånge	jordnötter	130.00  kr	1	Awaiting Payment
    3	Caps	Johan Rånge	jordnötter	30.00  kr	1	Awaiting Payment

    I suppose I could find and change it somewhere in the phpcode but Im new to wordpress and not very good at PHP. So before I buy I would like to now I can fix this. And also how does the CSV look like with the multiple attende?

    http://ww.wp.xz.cn/extend/plugins/events-manager/

Viewing 3 replies - 1 through 3 (of 3 total)
  • 99% chance it’s an excel issue? Sadly, Excel doesn’t deal well with encoding.

    I’m told importing/exporting the file via google docs from csv to xls sets things right.

    Thread Starter Hydeisch

    (@hydeisch)

    It is an encoding issue and I can open it in Notepad and save it as ANSII and then import data in excel to get it nicely formatted.

    But will there be any HTML/XML eportations possible in the future? Im struggling with getting the list of the attendees to show in a favorable way.

    Also, can I display all attendess on a page?

    Hi.
    Here is a patch for em-actions.php [EM5.3.6.1] which i use to export CSV file in Shift_JIS encoding. It’s a quick and dirty code, but works fine in my purpose.
    I hope it is helpful to export CSV file in other encoding.

    diff -c em-actions.php.orig em-actions.php

    *** em-actions.php.orig	Sun Mar 03 00:45:17 2013
    --- em-actions.php	Thu Mar 14 01:09:46 2013
    ***************
    *** 578,600 ****
      		//generate bookings export according to search request
      		$show_tickets = !empty($_REQUEST['show_tickets']);
      		$EM_Bookings_Table = new EM_Bookings_Table($show_tickets);
    ! 		header("Content-Type: application/octet-stream; charset=utf-8");
      		$file_name = !empty($EM_Event->event_slug) ? $EM_Event->event_slug:get_bloginfo();
      		header("Content-Disposition: Attachment; filename=".sanitize_title($file_name)."-bookings-export.csv");
      		do_action('em_csv_header_output');
      		if( !defined('EM_CSV_DISABLE_HEADERS') || !EM_CSV_DISABLE_HEADERS ){
      			if( !empty($_REQUEST['event_id']) ){
    ! 				echo __('Event','dbem') . ' : ' . $EM_Event->event_name .  "\n";
    ! 				if( $EM_Event->location_id > 0 ) echo __('Where','dbem') . ' - ' . $EM_Event->get_location()->location_name .  "\n";
    ! 				echo __('When','dbem') . ' : ' . $EM_Event->output('#_EVENTDATES - #_EVENTTIMES') .  "\n";
      			}
    ! 			echo sprintf(__('Exported booking on %s','dbem'), date_i18n('D d M Y h:i', current_time('timestamp'))) .  "\n";
      		}
    ! 		echo '"'. implode('","', $EM_Bookings_Table->get_headers(true)). '"' .  "\n";
      		//Rows
      		$EM_Bookings_Table->limit = 150; //if you're having server memory issues, try messing with this number
      		$EM_Bookings = $EM_Bookings_Table->get_bookings();
    ! 		$handle = fopen("php://output", "w");
      		while(!empty($EM_Bookings->bookings)){
      			foreach( $EM_Bookings->bookings as $EM_Booking ) {
      				//Display all values
    --- 578,602 ----
      		//generate bookings export according to search request
      		$show_tickets = !empty($_REQUEST['show_tickets']);
      		$EM_Bookings_Table = new EM_Bookings_Table($show_tickets);
    !
    ! 		header("Content-Type: application/octet-stream; charset=Shift_JIS");
      		$file_name = !empty($EM_Event->event_slug) ? $EM_Event->event_slug:get_bloginfo();
      		header("Content-Disposition: Attachment; filename=".sanitize_title($file_name)."-bookings-export.csv");
      		do_action('em_csv_header_output');
      		if( !defined('EM_CSV_DISABLE_HEADERS') || !EM_CSV_DISABLE_HEADERS ){
      			if( !empty($_REQUEST['event_id']) ){
    ! 				echo mb_convert_encoding( __('Event','dbem') . ' : ' . $EM_Event->event_name .  "\n", 'Shift_JIS', 'UTF-8');
    ! 				if( $EM_Event->location_id > 0 ) echo mb_convert_encoding( __('Where','dbem') . ' - ' . $EM_Event->get_location()->location_name .  "\n" , 'Shift_JIS', 'UTF-8');
    ! 				echo mb_convert_encoding( __('When','dbem') . ' : ' . $EM_Event->output('#_EVENTDATES - #_EVENTTIMES') .  "\n", 'Shift_JIS', 'UTF-8');
      			}
    ! 			echo mb_convert_encoding( sprintf(__('Exported booking on %s','dbem'), date_i18n('Y/m/d H:i', current_time('timestamp'))) .  "\n", 'Shift_JIS', 'UTF-8');
      		}
    ! 		echo mb_convert_encoding( '"'. implode('","', $EM_Bookings_Table->get_headers(true)). '"' .  "\n", 'Shift_JIS', 'UTF-8');
      		//Rows
      		$EM_Bookings_Table->limit = 150; //if you're having server memory issues, try messing with this number
      		$EM_Bookings = $EM_Bookings_Table->get_bookings();
    !
    ! 		$handle = fopen("php://temp", "r+");
      		while(!empty($EM_Bookings->bookings)){
      			foreach( $EM_Bookings->bookings as $EM_Booking ) {
      				//Display all values
    ***************
    *** 614,619 ****
    --- 616,627 ----
      			$EM_Bookings_Table->offset += $EM_Bookings_Table->limit;
      			$EM_Bookings = $EM_Bookings_Table->get_bookings();
      		}
    + 		rewind($handle);
    + 		$utf = stream_get_contents($handle);
    + 		fclose($handle);
    + 		$handle = fopen("php://output", "w");
    + 		$sjis = mb_convert_encoding($utf, 'Shift_JIS', 'UTF-8');
    + 		fwrite($handle, $sjis);
      		fclose($handle);
      		exit();
      	}
Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Text encoding in CSV file’ is closed to new replies.