public function upload() { $this->layout->body_class = 'user'; if (Input::hasFile('file')) { if (Input::file('file')->isValid()) { $validExtensions = array('csv'); if (in_array(Input::file('file')->getClientOriginalExtension(), $validExtensions)) { $file = new DataFile(); $file->name = Input::file('file')->getClientOriginalName(); $file->status = 'Pending'; $file->save(); Input::file('file')->move(storage_path() . '/uploads/', $file->id . '.' . Input::file('file')->getClientOriginalExtension()); return Redirect::route('get.admin.upload')->with('message', 'File uploaded successfully'); } else { return Redirect::route('get.admin.upload')->with('message', 'Only files csv extension are allowed'); } } else { return Redirect::route('get.admin.upload')->with('message', 'An error occurred while reading the file'); } } else { return Redirect::route('get.admin.upload')->with('message', 'Please select a file to be uploaded'); } }
public function __construct($file) { parent::__construct($file); $this->filesize = filesize($file); if (($this->fp = fopen($this->file, "r")) === false) { usage("Please specify the name of a spreadsheet to import: " . $file . " is not openable"); } }
<?php include 'data.php'; header('Content-Type: application/json'); $w = $_GET['wrk']; $c = $_GET['conc']; $ser = $_GET['server']; $samp = array(1, 2, 3); $data = array(); foreach ($samp as $s) { // echo "Collating data from results/$ser/$w-workers/AB-".$c."C-$s.txt"; $df = new DataFile($ser, "results/{$ser}/{$w}-workers/AB-" . $c . "C-{$s}.txt"); if ($df->getTPS() != null) { array_push($data, $df); } } echo json_encode($data);
public static function importOnce() { $dir = dir('D:\\wamp\\www\\ForeShadowAlpha\\data\\tmp'); $filelist = array(); while (($file = $dir->read()) !== false) { if (substr($file, 0, 3) == 'ths') { //echo "filename: " . $file . "<br />"; $filelist[] = $file; } } $dir->close(); sort($filelist); //print_r($filelist); //echo '<!DOCTYPE html><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title></title></head><body>'; //$i = 1; foreach ($filelist as $file) { //if ( --$i < 0 ) exit(0); //echo "filename: " . $file . "<br />"; $content = DataFile::getFileContent('D:\\wamp\\www\\ForeShadowAlpha\\data\\tmp/' . $file); //echo $content; $rows = explode("\n\r", $content); if (!$file) { continue; } foreach ($rows as $row) { if (!$row) { continue; } $lie = explode('|', $row); //get Code $r = "/[0-9]{6}/"; preg_match($r, $lie[0], $code); //echo $lie[0] . $code[0]; $c = $code[0]; $r = substr($code[0], 0, 1); if ($r == '6') { $code = 'sh' . $c; } else { if ($r == '0') { $code = 'sz' . $c; } else { if ($r == '3') { $code = 'sz' . $c; } } } //echo $code . "<br />"; $thsPath = 'D:\\wamp\\www\\ForeShadowAlpha\\data\\thsdoctor/'; $thsFile = $thsPath . $code . '.txt'; echo $thsFile . "<br />"; $thsRow = array(); //time $r = "/[0-9.]+/"; preg_match_all($r, $lie[3], $k); //if (sizeof($k) < 5 ) continue; $t = $k[0][0] . '-' . $k[0][1] . '-' . $k[0][2]; //echo $t. "<br />"; //echo $k[0][3]. "<br />"; $thsRow['time'] = $t; $thsRow['hour'] = $k[0][3] . ':' . $k[0][4]; //total $r = "/([0-9.]+)分/"; preg_match($r, $lie[2], $k); //echo $k[0].'--'.$k[1]."<br />"; $thsRow['total_score'] = $k[1]; $thsRow['total_text'] = $lie[13]; //shot_trend $thsRow['shot_trend'] = $lie[5]; //mid_trend $thsRow['mid_trend'] = $lie[6]; //long_trend $thsRow['long_trend'] = $lie[7]; //technical $r = "/([0-9.]+)/"; preg_match($r, $lie[8], $k); $thsRow['technical_score'] = $k[0]; //echo $k[0]."<br />"; $k = trim($lie[8]); $kk = preg_split('/\\s/', $k, -1, PREG_SPLIT_NO_EMPTY); $thsRow['technical_text'] = end($kk); //funds $r = "/([0-9.]+)/"; preg_match($r, $lie[9], $k); $thsRow['funds_score'] = $k[0]; //echo $k[0]."<br />"; $k = trim($lie[9]); $kk = preg_split('/\\s/', $k, -1, PREG_SPLIT_NO_EMPTY); $thsRow['funds_text'] = end($kk); //message $r = "/([0-9.]+)/"; preg_match($r, $lie[10], $k); $thsRow['message_score'] = $k[0]; //echo $k[0]."<br />"; $k = trim($lie[10]); $kk = preg_split('/\\s/', $k, -1, PREG_SPLIT_NO_EMPTY); $thsRow['message_text'] = end($kk); //trade $r = "/([0-9.]+)/"; preg_match($r, $lie[11], $k); $thsRow['trade_score'] = $k[0]; //echo $k[0]."<br />"; $k = trim($lie[11]); $kk = preg_split('/\\s/', $k, -1, PREG_SPLIT_NO_EMPTY); $thsRow['trade_text'] = end($kk); //basic $r = "/([0-9.]+)/"; preg_match($r, $lie[12], $k); $thsRow['basic_score'] = $k[0]; //echo $k[0]."<br />"; $k = trim($lie[12]); $kk = preg_split('/\\s/', $k, -1, PREG_SPLIT_NO_EMPTY); $thsRow['basic_text'] = end($kk); //print_r($thsRow); //echo "<br />"; TableFile::putSomeData($thsFile, array($thsRow)); } } }