Sanjoy Roy

[MCM, MCP, SCJP] – Senior Programmer, Sites n Stores Pty Ltd.

Tag Archives: Parser

Parse .xls (Excel) using PHP

XLSParser.php: if ($fileType !=” && $fileType == ‘application/vnd.ms-excel’){ //parse xsl file $ext = ‘xls’; $filename = $user.’.’.$section.’.upload.’.date(‘Ymd’).’.’.$ext; copy($_FILES['file']['tmp_name'], $UPLOAD_CSV_PATH.$filename); require_once ‘../includes/reader.php’; $data = new Spreadsheet_Excel_Reader(); //set output encoding $data->setOutputEncoding(‘CP1251′); //read the excel file through api $data->read($UPLOAD_CSV_PATH.$filename); //prepare to retun result $actual_data = $data->sheets[0]['cells']; $rowsLength = array(); for($i=1; $i<$max_nos; $j++){ $allColumns[$j] = $actual_data[$i][$j]; } $newRowData[] = [...]

Parse .CSV using PHP

CSVParser.php: if ($fileType !=” && $fileType == ‘text/comma-separated-values’){ //parse csv file $ext = ‘csv’; $filename = $user.’.’.$section.’.upload.’.date(‘Ymd’).’.’.$ext; copy($_FILES['file']['tmp_name'], $UPLOAD_CSV_PATH.$filename); $row = 1; $fhandle = @fopen($UPLOAD_CSV_PATH.$filename, “r”); $columnHeaders = ”; $columnNames = ”; $rawData = array(); $count = 0; while (($fdata = fgetcsv($fhandle, 1000, $terminated_by, $enclosed_by)) !== FALSE) { $len = count($fdata)-1; if (strlen($fdata[$len])==0) array_pop($fdata); $rawData[$count] [...]

Parse XML Spreadsheet using PHP DOMDocument

xmlparser.html: File Name:   Options: Column Heading Included Column Heading & Name Included Just Data   Hidden Parameters:   xmlparser.php: $fileType = isset($_FILES['file']['type']) ? $_FILES['file']['type']: ”; if ($fileType !=” && $fileType == ‘text/xml’){ $ext = ‘xml’; if ($_FILES['file']['tmp_name']){ //Copy to the backup directory $filename = $user.’.’.$section.’.upload.’.date(‘Ymd’).’.’.$ext; copy($_FILES['file']['tmp_name'], $UPLOAD_CSV_PATH.$filename); //parse xml spredsheet $dom = DOMDocument::load($UPLOAD_CSV_PATH.$filename); $rows [...]

Follow

Get every new post delivered to your Inbox.