0

I'm trying to import csv file using Laravel-excel composer package, but that csv file inside deferent that usual csv files, then I found by changing config of default Laravel-excel package can make it import. but i cannot identified what is the config for the this csv file.

here example csv data

id  created_time    ad_id   ad_name adset_id    adset_name  campaign_id campaign_name           
l:132562915446228   2021-03-03T13:45:28+05:30   ag:23847391487180225    "Campaign 2021 feb" as:23847391487170225    
l:3689145127872575  2021-03-03T07:20:04+05:30   ag:23847391487180225    "Campaign 2021 feb" as:23847391487170225    
l:2374231269367799  2021-03-03T00:54:03+05:30   ag:23847391487180225    "Campaign 2021 feb" as:23847391487170225    
l:425446045204770   2021-03-02T18:44:41+05:30   ag:23847391487180225    "Campaign 2021 feb" as:23847391487170225    
l:184810853442455   2021-03-02T18:42:23+05:30   ag:23847391487180225    "Campaign 2021 feb" as:23847391487170225    
l:256522452772718   2021-03-02T17:11:56+05:30   ag:23847391487180225    "Campaign 2021 feb" as:23847391487170225    
l:1142930659490759  2021-03-02T12:13:24+05:30   ag:23847391487180225    "Campaign 2021 feb" as:23847391487170225    

current csv import config:

 'csv'         => [
            'delimiter'        => ',',
            'enclosure'        => '"',
            'escape_character' => '\\',
            'contiguous'       => false,
            'input_encoding'   => 'UTF-8',
        ],

i just need valid config for import this csv

vidur
  • 93
  • 1
  • 7

1 Answers1

0

i fixed this by adding use WithCustomCsvSettings concern to my imporitng class and adding configuation from inside class. here it is

<?php

use Maatwebsite\Excel\Concerns\WithCustomCsvSettings;


class Import implements  WithCustomCsvSettings
{


    //set csv configs
    public function getCsvSettings(): array
    {
        return [
            'delimiter' => "\t",
            'enclosure'        => '',
            'escape_character' => '\\',
            'contiguous'       => false,
            'input_encoding'   => 'UTF-8', // if this not worked use `UCS-2`
        ];
    }
}
vidur
  • 93
  • 1
  • 7