开发者

Convert a raw comma separated file into .xlsx type in ubuntu?

How do you convert a raw csv file (which has 1.6GB size) into开发者_Go百科 .xlsx type in linux command without opening that file.Since it couldn't be opened by the 2GB ram.so as it need to be converted into xlsx type .

Also Is there any alternative way to process this kinda file?


It's PHP based...

Pre-requisite: PHP support, ie. php server, use XAMPP...

Go to following link & download: http://phpexcel.codeplex.com/

Unzip the file & Assuming u unzip it to /etc/phpExcel

Here is the code:

<?php

error_reporting(E_ALL);
date_default_timezone_set('Europe/London');

/** PHPExcel_IOFactory */

require_once '/etc/PHPExcel/Classes/PHPExcel/IOFactory.php';

$file=""; //PATH TO CSV FILE`

// Check prerequisites

if (!file_exists($file)) {
    exit("Please run 06largescale.php first.\n");
}

$objReader = PHPExcel_IOFactory::createReader('CSV');`
$objPHPExcel = $objReader->load($file);

$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save(str_replace('.csv', '.xlsx',$file));
?>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜