Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (Input::hasFile('file')) {
- ini_set('memory_limit', '1024M');
- $f = Input::file('file');
- $bulkdata = [];
- $handle = fopen("$f", "r") or die("Couldn't get handle");
- if ($handle) {
- $i = 1;
- while (!feof($handle)) {
- $buffer = fgets($handle);
- if ($buffer[0] != '#') {
- $carry1 = preg_split("~\s+~", $buffer);
- /*echo '<pre>';
- print_r(sizeof($carry1));*/
- if (sizeof($carry1) == 5) {
- $data = [
- 'user_id' => Auth::id(),
- 'snp' => $carry1[0],
- 'chromosome' => $carry1[1],
- 'position' => $carry1[2],
- 'genotype' => $carry1[3],
- "created_at"=> Carbon::now(),
- "updated_at"=> Carbon::now()
- ];
- $i++;
- array_push($bulkdata, $data);
- }
- }
- }
- /* echo '<pre>';
- print_r($bulkdata);*/
- fclose($handle);
- $insert_data = collect($bulkdata); // Make a collection to use the chunk method
- $chunks = $insert_data->chunk(1000);
- foreach ($chunks as $chunk) {
- Dnaupload::insert($chunk->toArray());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement