Seite 1 von 1

Restoring call logs to new or upgraded phone

Verfasst: Di 19. Jun 2012, 21:06
von epp_b
I've written a script that converts the CSV file of call logs exported from MyPhoneExplorer to an XML file that can be used with Call Logs Backup & Restore to restore all your call history to an Android phone if you've upgraded the OS (and it deleted your call history) or need to get your call logs from your old Android phone to your new one.

It's a PHP script that needs a web server to run. You can try it here, but I'm not going to leave it up permanently. I've tested it with Android 2.3.4 (upgraded from 2.1) on a Linux/Apache environment, but that's it. It should work in other environments, but I can't make any guarantees.

Does FJ software want a copy to host it themselves?

Verfasst: Mi 20. Jun 2012, 13:37
von epp_b
Correction: Android 2.3.7 (Cyanogenmod 7.1.0)

Verfasst: Mi 27. Jun 2012, 00:24
von FJ
Many thanks, i will host it but i'll need the source file, please send it to me zipped via email

Verfasst: Do 28. Jun 2012, 16:25
von epp_b
Actually, it's a very short file, I'll just post the code here:

Code: Alles auswählen

<?php
// CSV to XML converter for MyPhoneExplorer
// Public domain: use, reuse, peruse and abuse :)

// file uploaded
if (count($_FILES)) {

	// open uploaded file for reading
	$f = fopen($_FILES['csvfile']['tmp_name'], 'r');
	
	// iterator
	$i = 0;
	
	// init output var
	$xmlout = array();
		
	// call type (Storage)	
	$CallTypes = array('DC', 'RC', 'MC');
	
	// loop through CSV data
	while ($csvline = fgetcsv($f, 1024, ',', '"')) {
		
		// first line, get headings
		if ($i == 0) {
			$headings = $csvline;
			$i++;
			continue;
		}
		
		// populate data from headings
		foreach ($headings AS $j => $heading)
			${$heading} = $csvline[$j];
		
		// generate UNIX timestamp from standard timestamp
		list($stampdate, $stamptime) = explode(' ', $Time);
		list($yr,$mo,$da) = explode('-', $stampdate);
		list($hr,$mn,$sc) = explode(':', $stamptime);
		
		// OUTPUT
		$xmlout[] = "  <call number=\"$Number\" duration=\"$Duration\" date=\"" . mktime($hr,$mn,$sc,$mo,$da,$yr) . "000\" type=\"" . (array_search($Storage, $CallTypes)+1) . "\" />";
		
		$i++;
	}
	
	// file population of data
	$xml_start = '<' . "?xml version='1.0' encoding='UTF-8' standalone='yes' ?" . ">\r\n<calls count=\"" . count($xmlout) . "\">\r\n";
	$xml_end   = "\r\n</calls>";
	
	// output as XML file to save
	header('Content-Type: text/xml');
	header('Content-Disposition: attachment; Filename="calls-restored.xml"');
	echo $xml_start . implode("\r\n", $xmlout) . $xml_end;
	exit;
}

// Output upload form...
?>

<div align="center" style="margin-top: 25px">
	<div style="font-size: 20px">CSV to XML converter for MyPhoneExplorer / Android Call Log</div>
	<div style="padding: 25px; text-align: center; width: 600px; border: 1px dotted #000000; margin-top: 5px">
	<form name="csv2xml" method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>" style="margin: 0px" enctype="multipart/form-data">
	CSV file from MyPhoneExplorer: <input type="file" name="csvfile">
	<input type="submit" value="convert" style="font-weight: bold">
	</form>
	</div>
</div>
Copy and save as .php file. Make sure your php.ini file is configured accept file uploads.

Verfasst: Do 5. Jul 2012, 10:42
von ajeet
I tried this utility to generate the xml file. However, there are some errors . The contents cannot be viewed using CallLogBackup&Restore. The dates and time seem incorrect and there is no duration.

New Phone

Verfasst: Fr 6. Jul 2012, 10:59
von markfitz
Hi Firstly thanks heaps for the great amazing wonderful software it rocks................I havea samsung galaxy 2 and i dropped it and got a new one, when I sync up it synced with my outlook prefectly however I cannot work out how to sync my sms and calls ...is this possible????

Cheers Mark

Verfasst: Sa 7. Jul 2012, 23:25
von FJ
@epp_b: Many thanks again, its hosted now on my site, you can delete your converter.

@ajeet: Please try the hosted version on my site, since CSV-Files are language specific i had to adapt some things so the right format gets autodetected.

Convert exported call list from MyPhoneExplorer to XML-File for Call Logs Backup & Restore

@mark: For SMS you should use Menu-Extras-Create backup/Restore backup. For calls its currently not implemented but you can use the workaround which is handled in this thread

Verfasst: So 8. Jul 2012, 07:48
von ajeet
Hi FJ, I tried the version on your site but it too does not show the date, time and duration correctly. Perhaps I will send you the calls dat and the corresponding CSV file created. You could maybe look into.
Cheers.

Verfasst: Sa 21. Jul 2012, 23:00
von FJ
Now near all problems has been fixed. I think now its a acceptable workaround

Verfasst: Do 26. Jul 2012, 06:35
von epp_b
I tried this utility to generate the xml file. However, there are some errors . The contents cannot be viewed using CallLogBackup&Restore. The dates and time seem incorrect and there is no duration.
Hmm, I didn't actually try to view the log on my phone, I just restored it and it worked. Has this been fixed by FJ already?
@ajeet: Please try the hosted version on my site, since CSV-Files are language specific i had to adapt some things so the right format gets autodetected.
Yup, sorry, I should have said that it was English-only (sorry, I only know very little German :))
Hi Firstly thanks heaps for the great amazing wonderful software it rocks................I havea samsung galaxy 2 and i dropped it and got a new one, when I sync up it synced with my outlook prefectly however I cannot work out how to sync my sms and calls ...is this possible????
The SMS file will use different variables and formatting, so the script would need to be updated to handle that.

However, as MPE can restore SMS to the phone, this would be redundant.
Hi FJ, I tried the version on your site but it too does not show the date, time and duration correctly. Perhaps I will send you the calls dat and the corresponding CSV file created. You could maybe look into.
Cheers.
Maybe post a sample of the CSV file with the names/numbers changed so we can see what it looks like?

Verfasst: Mo 30. Jul 2012, 22:47
von FJ
MyPhoneExplorer can already upload messages from SMS-Archive to the phone so no need to create another script

Verfasst: Mi 1. Aug 2012, 17:13
von epp_b
MyPhoneExplorer can already upload messages from SMS-Archive to the phone so no need to create another script
True, although it takes a really long time if you've got a lot of messages. SMS B&R is quite a bit faster, so there may be some utility in having an conversion script for SMS.

Verfasst: Sa 22. Dez 2012, 18:00
von Yanbi
[quote="FJ"]@epp_b: Many thanks again, its hosted now on my site, you can delete your converter.

..

Convert exported call list from MyPhoneExplorer to XML-File for Call Logs Backup & Restore

..

Very good
Thanks :D

Verfasst: Fr 26. Apr 2013, 03:31
von epp_b
Just to update: I just ran a file through this script on FJ's server and restored the file successfully with CLB&R on the very latest version of Android :)

Android 5

Verfasst: So 11. Okt 2015, 03:23
von taloncc
I just tried to use this and had all kinds of errors. I had to adjust for date/time format of USA.

here are my mods.

This one is meant to be run at the command line with your file named export.csv.

ie php export.csv > exportoutput.xml

Code: Alles auswählen

<?php 
// CSV to XML converter for MyPhoneExplorer 
// Public domain: use, reuse, peruse and abuse :) 
date_default_timezone_set('America/Chicago');
$file = "export.csv";

   // open uploaded file for reading 
   $f = fopen($file, 'r'); 
    
   // iterator 
   $i = 0; 
    
   // init output var 
   $xmlout = array(); 
       
   // call type (Storage)    
   $CallTypes = array('DC', 'RC', 'MC'); 
    
   // loop through CSV data 
   while ($csvline = fgetcsv($f, 1024, ',', '"')) { 
       
      // first line, get headings 
      if ($i == 0) { 
         $headings = $csvline; 
         $i++; 
         continue; 
      } 
       
      // populate data from headings 
      foreach ($headings AS $j => $heading) 
         ${$heading} = $csvline[$j]; 
       
      // generate UNIX timestamp from standard timestamp 
      list($stampdate, $stamptime, $am) = explode(' ', $Time);
	  $stamptime = $stamptime . " " . $am;
	  //echo "\n" . $stamptime . " - ";
	  $stamptime = date("H:i", strtotime($stamptime));  
	  //echo $stamptime . "\n";	  
      list($mo,$da,$yr) = explode('/', $stampdate); 
	  //echo $mo . "-" . $da . "-" . $yr . "\n";
      list($hr,$mn,$sc) = explode(':',  $stamptime); 
	  //echo $hr . "-" . $mn . "-" . $sc. "\n";
      $sc = "00"; 
      // OUTPUT 
      $xmlout[] = "  <call number=\"$Number\" duration=\"$Duration\" date=\"" . mktime($hr,$mn,$sc,$mo,$da,$yr) . "000\" type=\"" . (array_search($Storage, $CallTypes)+1) . "\" />"; 
       
      $i++; 
   } 
    
   // file population of data 
   $xml_start = '<' . "?xml version='1.0' encoding='UTF-8' standalone='yes' ?" . ">\r\n<calls count=\"" . count($xmlout) . "\">\r\n"; 
   $xml_end   = "\r\n</calls>"; 
    
   // output as XML file to save 
   header('Content-Type: text/xml'); 
   header('Content-Disposition: attachment; Filename="calls-restored.xml"'); 
   echo $xml_start . implode("\r\n", $xmlout) . $xml_end; 
   exit; 
 

// Output upload form... 
?>