Skip to content

Commit 66b5a99

Browse files
committed
Added Chunk Support
1 parent 3410881 commit 66b5a99

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function download(Request $request)
5858

5959
#### Extended Options
6060
```
61-
SimpleCsv::import($path = '/some/file.csv', $delimiter = ",", $enclosure = "\"", $escape = "\\");
61+
SimpleCsv::import($path = '/some/file.csv', $callback = function, $chunk = 500, $delimiter = ",", $enclosure = "\"", $escape = "\\");
6262
SimpleCsv::export($collection, $delimiter = ",", $enclosure = "\"", $escape = "\\");
6363
```
6464

@@ -115,6 +115,15 @@ DB::transaction(function(){
115115
});
116116
```
117117

118+
Expose chunk callback to generator allowing lower memory consumption for large files:
119+
```
120+
DB::transaction(function(){
121+
SimpleCsv::import(storage_path('table.csv'), function($chunk){
122+
DB::insert($chunk->toArray());
123+
}, 1000);
124+
});
125+
```
126+
118127
#### DebugBar Timeline Results:
119128

120129
| Operation | Chunk | Total Entries | Total Memory | Framework Memory | Actual Memory | Total Time | Framework Time | Actual Time |

0 commit comments

Comments
 (0)