Replies: 2 comments
-
I think in this situation it's probably best to just open the Csv via file_get_contents (or something alike) and doing that check how you want; and with that determining the headingRow. We don't have any way to detect something like that. |
Beta Was this translation helpful? Give feedback.
0 replies
-
So this is a bit of a hack but it makes it possible to use Laravel-Excel, without needing to open the file manually.
And in CustomImport:
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Prerequisites
[X] Have read and understood: https://github.com/Maatwebsite/Laravel-Excel/blob/3.1/.github/SUPPORT.md
[X] Checked if your Laravel Excel version is still supported: https://docs.laravel-excel.com/3.1/getting-started/support.html#supported-versions
[X] Checked that your question isn't already asked before.
[X] Filled in the entire issue template
Versions
PHP version: 7.4.15
Laravel version: 8.34.0
Package version: 3.1.29
Description
I recently came across a CSV file that is starting with an additional line at the beginning of the file looking like this :
#CSV DD V2.4.3
The following line is where the Heading Row data is.
So, I'm working with CSV files that could have that extra first line or not without any way to determine it beforehand except looking in the CSV file itself (which is something that I would like to achieve via Laravel-excel)
I was using the
HeadingRowImport
class before finding this weird CSV file.Is there a way, in the
HeadingRowImport
, to determine before importing what theheaderRow
starting line number should be before the import start ?Additional informations
I've looked at how to extend with events BeforeImport and wonder if it's possible to get the first two lines of the CSV files (in an array for example to check if that first line start with a
#
), and be able to set theheadingRow
dynamically before the import to point exactly where the headings' informations are ?I can see
read
,toArray
,toCollection
but they all seems to require passing the path of the file to be imported again and it seems to be not a good way to achieve this.Beta Was this translation helpful? Give feedback.
All reactions