goodby/csvでtsvを取り込む処理を作成しています。
しかし、一部文字が混在する際に、tabを無視してしまっています。
取り込みデータ(例
2016-09-30T00:00:00+09:00 bbbb aaaaa 『並行輸入品』 2 FSZ1 販売可 JP
2016-09-30T00:00:00+09:00 cccc ddddd ビデオデッキ 1 FSZ1 販売可 JP
期待する結果
『並行輸入品』 2 がで区切られている =>区切られずつながってしまう。
エラーメッセージ
at HandleExceptions->handleError('8', 'Undefined offset: 7', 'C:\xampp7\htdocs\codehacking\app\Http\Controllers\AdminUploadController.php', '200', array('columns' => array('2016-09-30T00:00:00+09:00', 'bbbb', 'aaaaa', '『並行輸入品』 2', 'FSZ1', '販売可', 'JP'))) in AdminUploadController.php line 200
この場合、どのような設定をさせると、上手く取得できますでしょうか。
php
1 DB::table('fba_inventories')->truncate(); 2 3 $file = Input::file('fba_inventories'); 4 $fileName = $file->getClientOriginalName() . '_' . time(); 5 $move = $file->move(storage_path() . '/upload', $fileName); 6 7 // return print $move; 8 9 10 11 //CSVのパース 12 $config = new LexerConfig(); 13 $config->setDelimiter("\t") 14 ->setToCharset("UTF-8") // Customize file encoding. Default value is null, no converting. 15 ->setFromCharset("SJIS-win") // Customize source encoding. Default value is null. 16 ->setIgnoreHeaderLine(false) 17 ->setEscape("\\"); 18 19 $interpreter = new Interpreter(); 20 21 22 $interpreter->addObserver(function (array $columns) { 23 24// return print $columns[3].":".$columns[4]; 25 26 // CSVファイルを1行ずつ処理 27 DB::table('fba_inventories')->insert( 28 [ 29// 'id' =>'', 30 'date' => $columns[0], 31 'fnsku' => $columns[1], 32 'sku' => $columns[2], 33 'name' => $columns[3], 34 'number' => $columns[4], 35 'fc' => $columns[5], 36 'status' => $columns[6], 37 'country' => $columns[7] 38 ] 39 ); 40 }); 41 42 43 $lexer = new Lexer($config); 44 $lexer->parse($move, $interpreter); 45 46 return back(); 47 48 49

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/10/01 23:04
退会済みユーザー
2016/10/01 23:33 編集
2016/10/02 03:06
退会済みユーザー
2016/10/02 03:28
2016/10/02 06:23
退会済みユーザー
2016/10/02 07:51
退会済みユーザー
2016/10/02 08:01
2016/10/02 08:07
退会済みユーザー
2016/10/02 08:55
2016/10/02 23:11
退会済みユーザー
2016/10/03 00:14
退会済みユーザー
2016/10/03 00:20
退会済みユーザー
2016/10/03 01:12
退会済みユーザー
2016/10/03 03:24 編集
退会済みユーザー
2016/10/05 02:58 編集
退会済みユーザー
2016/10/05 03:25 編集