Laravel-excel: [QUESTION] How to dynamic set encoding when import CSV file

Created on 18 Sep 2017  ·  3Comments  ·  Source: Maatwebsite/Laravel-Excel

Package version, Laravel version

Laravel 5.4
maatwebsite/excel 2.1.22

Expected behaviour

I want to know how to dynamic set encoding when import from CSV file when use chunk importer

Actual behaviour

All data is not UTF-8 will be remove

CSV File

https://drive.google.com/file/d/0Bz-YEwnA8p4RTWRHQ09GSDQxWnc/view?usp=sharing

Most helpful comment

@aliusa
Oh I am sorry,
I want to know how to dynamic set encoding when use chunk importer. I forgot to add this to question

All 3 comments

Have you tried the way docs says?

// When utilising a closure, you can pass the input encoding as third parameter.
Excel::load('filename.csv', function($reader) {

}, 'UTF-8');

@aliusa
Oh I am sorry,
I want to know how to dynamic set encoding when use chunk importer. I forgot to add this to question

For people who stumble on this issue from Google Search like I did, this part of the documentation solves this issue: https://docs.laravel-excel.com/3.1/imports/custom-csv-settings.html
You can pass the encoding in the constructor of the Import Class that you create.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vandolphreyes picture vandolphreyes  ·  3Comments

alejandri picture alejandri  ·  3Comments

matthewslouismarie picture matthewslouismarie  ·  3Comments

octoxan picture octoxan  ·  3Comments

daraghoshea picture daraghoshea  ·  3Comments