Laravel-excel: HELP! Special Characters like ñ will convert a word into number 0 on import

Created on 1 Mar 2020  ·  5Comments  ·  Source: Maatwebsite/Laravel-Excel

Prerequisites

Versions

  • PHP version: 7.2
  • Laravel version: 5.8
  • Package version: ^3.1

Description


I have a CSV file with some rows that has text/words that contain a special character like ñ, what happened is that when I tried to import the file the words with characters above or alike will be converted to 0. Not sure if it is related to encoding, I found some solutions in the StackOverflow but none of them seem to work.

Additional Information

I am using the ToModel
use Maatwebsite\Excel\Concerns\ToModel;

To reproduce this, just try to put a special character in one of the cell of your CSV, then import it like:
Excel::import(new CsvImport, request()->file('file'));

The resulting inserted data that has a special character will be stored as 0

question

Most helpful comment

did any of you guys experience this one?

All 5 comments

did any of you guys experience this one?

Yes me too @fmsthird

same here @fmsthird

Try setting the input encoding to the encoding that your file is in: https://github.com/Maatwebsite/Laravel-Excel/blob/3.1/config/excel.php#L76

The issue is the csv files are generated from a third part system i have no control over and came with charset=unknown-8bit so the encoding is not defined on the source file and to loop through every character the csv files contains hundreds of thousand rows which may time out before completion

Was this page helpful?
0 / 5 - 0 ratings

Related issues

thearabbit picture thearabbit  ·  3Comments

matthewslouismarie picture matthewslouismarie  ·  3Comments

daraghoshea picture daraghoshea  ·  3Comments

ellej16 picture ellej16  ·  3Comments

alejandri picture alejandri  ·  3Comments