Commit Graph

19 Commits

Author SHA1 Message Date
Mateusz Charytoniuk 318e9d7e76 Import CSV rows one at a time (#3450)
Credit @mcharytoniuk.

While importing over 250k records ImportModel kept running into various problems. One of them was too big memory usage - `ImportModel` loaded the complete file upfront (`$reader->fetchAll()`). Simple one-line change to `$reader->fetch()` makes `ImportModel` import CSV file row-by-row and returning an iterator which limits memory usage and allows data to be imported. This change optimizes memory usage and allows much simpler importing of larger files.
2018-03-14 12:53:18 -06:00
Samuel Georges d30dd19b70 Rollback 510071550a
This issue has been addressed too early in the process lifecycle. The line number should be incremented later, say in the view layer when the error is displayed. A simple helper to determine what the index increment should do well.

$row + $indexIncrement

This is so we don't have to rebuild the array, which is computationally expensive for large datasets and could be frustrating for a developer expecting untouched index values, or likewise needing to prepare our special format.
2017-09-17 10:14:14 +10:00
Luke Towers 510071550a Report correct row number in import error logs
This fixes an issue where the row number reported by import error logs would be off by 1 or 2 depending on whether the first row was labelled as titles or not.

As arrays start at 0 in PHP, `$firstRowTitles = false` would result in reported row numbers being off by one less than their actual number. If `$firstRowTitles = true`, the reported row number would be off by two less than their actual number (one for the zero index, one for the first row not existing in the `$results` set).
2017-09-15 17:05:46 -06:00
Samuel Georges 00ddd8e2b4 string -> ::class + docs 2017-05-20 20:01:19 +10:00
Quezler cc17b679f1 Code dusting (#2826)
Code cleaning according to PSR-2 w/ exemptions (mostly dust).
2017-04-24 21:38:19 +10:00
Justin Lau 844d2d1b28 Use `id` instead of `updated_at` for more consistent behavior 2016-10-27 00:31:44 +08:00
Justin Lau 325ae4ad08 Return the latest uploaded (updated) file path. 2016-10-25 00:21:18 +08:00
Alexander Guth 61823329c8 ImportModel didnt respect encoding
In contrast to the preview CSV reader, the actual ``ImportModel`` did not respect any encoding values provided. This leads to bugs with any non utf8-compliant characters. This PR fixes the problem by adding the appropriate encoding filter (copied from the preview reader).
2016-08-18 21:11:21 +02:00
Samuel Georges 2ac23cc3c7 More peer review of #1856
Separation of concerns, the language file shouldn't really be treated as a data source for the supported encoding options.
2016-03-26 14:28:34 +11:00
Samuel Georges a035acdc2c Tidy up some logic, restore firstRowTitles setting
Refs #1856
2016-03-26 14:10:05 +11:00
Jérémy Gaulin 2a60e34558 Import options to configure the CSV reader + patch to prevent unfriendly error to be thrown due to bad import source file encoding (on AJAX request) 2016-03-26 12:54:13 +11:00
Samuel Georges 241ea68468 Add auto column match feature to import 2015-08-05 10:23:14 +10:00
Samuel Georges 8166c5ad6a Add encodeArrayValue | decodeArrayValue helpers 2015-08-04 20:03:24 +10:00
Samuel Georges d7eb4deac5 Merge pull request #1321 from Flynsarmy/filterEmptyCsvImportRowsClosure
Filter out empty CSV rows before import
2015-08-03 20:11:19 +10:00
flynsarmy 0dcda7a014 Only read permission is required for imports 2015-07-30 13:48:55 +10:00
flynsarmy f573438c90 Filter out empty CSV rows before import 2015-07-29 21:59:09 +10:00
Samuel Georges d0742653d1 Implement exporting function modeled after import function 2015-07-23 19:44:19 +10:00
Samuel Georges a9899ae3c1 Finish basic import workflow 2015-07-21 20:45:02 +10:00
Samuel Georges 5ca55e149a Create ImportModel base class, implement import_file uploader 2015-07-16 22:15:30 +10:00