Restoring call logs to new or upgraded phone

For user who dont speak german please use this part of my forum
Antworten
epp_b
Beiträge: 19
Registriert: Mo 4. Jun 2012, 18:14

Restoring call logs to new or upgraded phone

Beitrag 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?
epp_b
Beiträge: 19
Registriert: Mo 4. Jun 2012, 18:14

Beitrag von epp_b »

Correction: Android 2.3.7 (Cyanogenmod 7.1.0)
FJ
Site Admin
Beiträge: 32109
Registriert: Mi 15. Feb 2006, 01:16
Wohnort: Tirol

Beitrag von FJ »

Many thanks, i will host it but i'll need the source file, please send it to me zipped via email
Ich bitte um Verständnis daß ich aufgrund des hohen Aufkommens im Forum und meines zeitlichen Rahmens nichtmehr jeden Thread im Forum persönlich lesen bzw. beantworten kann.

Bitte benutzt auch die Forum-Suche bzw. die FAQ
epp_b
Beiträge: 19
Registriert: Mo 4. Jun 2012, 18:14

Beitrag 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.
Zuletzt geändert von epp_b am Mi 6. Feb 2013, 07:04, insgesamt 1-mal geändert.
ajeet
Beiträge: 4
Registriert: Mi 9. Mär 2011, 01:35

Beitrag 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.
markfitz
Beiträge: 1
Registriert: Fr 6. Jul 2012, 10:52

New Phone

Beitrag 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
FJ
Site Admin
Beiträge: 32109
Registriert: Mi 15. Feb 2006, 01:16
Wohnort: Tirol

Beitrag 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
Ich bitte um Verständnis daß ich aufgrund des hohen Aufkommens im Forum und meines zeitlichen Rahmens nichtmehr jeden Thread im Forum persönlich lesen bzw. beantworten kann.

Bitte benutzt auch die Forum-Suche bzw. die FAQ
ajeet
Beiträge: 4
Registriert: Mi 9. Mär 2011, 01:35

Beitrag 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.
FJ
Site Admin
Beiträge: 32109
Registriert: Mi 15. Feb 2006, 01:16
Wohnort: Tirol

Beitrag von FJ »

Now near all problems has been fixed. I think now its a acceptable workaround
Ich bitte um Verständnis daß ich aufgrund des hohen Aufkommens im Forum und meines zeitlichen Rahmens nichtmehr jeden Thread im Forum persönlich lesen bzw. beantworten kann.

Bitte benutzt auch die Forum-Suche bzw. die FAQ
epp_b
Beiträge: 19
Registriert: Mo 4. Jun 2012, 18:14

Beitrag 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?
FJ
Site Admin
Beiträge: 32109
Registriert: Mi 15. Feb 2006, 01:16
Wohnort: Tirol

Beitrag von FJ »

MyPhoneExplorer can already upload messages from SMS-Archive to the phone so no need to create another script
Ich bitte um Verständnis daß ich aufgrund des hohen Aufkommens im Forum und meines zeitlichen Rahmens nichtmehr jeden Thread im Forum persönlich lesen bzw. beantworten kann.

Bitte benutzt auch die Forum-Suche bzw. die FAQ
epp_b
Beiträge: 19
Registriert: Mo 4. Jun 2012, 18:14

Beitrag 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.
Yanbi
Beiträge: 2
Registriert: Sa 22. Dez 2012, 17:43
Wohnort: Vannes France

Beitrag 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
epp_b
Beiträge: 19
Registriert: Mo 4. Jun 2012, 18:14

Beitrag 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 :)
taloncc
Beiträge: 1
Registriert: So 11. Okt 2015, 03:19

Android 5

Beitrag 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... 
?> 
Antworten