I have this so far, but when I read from my csv I get an empty value because it is a non utf-8 encoded csv file.
public function process_woe()
{
$objPHPExcel = new PHPExcel();
$woe_processed = $objPHPExcel->setActiveSheetIndex( 0 );
$objReader = PHPExcel_IOFactory::load( $this->woe_filepath );
$woe = $objReader->getActiveSheet();
$rcount = 1;
$rncount = 1;
}
This string returns an empty string when I try to write it on a utf-8 encoding:
"Caruso�s Prostate EZE MAX health indications:
� Management of symptoms Medically Diagnosed Prostate Enlargement
� Prostate gland health
� Antioxidant for the prostate gland"
When I try to use setInputEncoding() I get an error, for example:
$objReader->setInputEncoding('ISO');
$woe->setInputEncoding('ISO-8859-7');
$woe->setInputEncoding('ISO-8859-1');
Fatal error: Uncaught Error: Call to undefined method PHPExcel_Worksheet::setInputEncoding() –
Related
I am working with an XML file that provides a base64 encoded PDF document. When I take the encoded string and enter it into the base64 to PDF converter located here it works fine and decodes to a valid PDF. However when I use PHP base64_decode($validStr) I get garbage back to the screen. Here is my code.
<?php
header("Content-type: application/pdf");
$imageParam=array(
'pCompanyID'=>1,
'pSysUser'=>'dburchfield',
'pDocID'=>588690
);
$wsdl="http://192.168.0.31/WSSmartConnect/cCustomerDocument.asmx?wsdl";
$client = new SoapClient($wsdl, array('trace' => 1));
$soapCall = $client->GetDocumentImage($imageParam);
$response = ($client->__getLastResponse());
$str = implode('', preg_split('/\s*/', $response));
$bin = base64_decode($str);
echo $bin;
?>
Here is the result when it renders on the web site:
�ioz�"�}tzw(v)������{ޖ�^�ig���m���r�j�f������������h���Y��ȡ���0�z+����_�0���隊{-jw�ig���i��0� ���M\��r�j���g��.���"f�y����{���m����u�2��&�g��.���"f�y��[IT�LK���x�����Hؚ����\H��][����Y�\�����Y�S[�H�\�S�ۙH�՚Y]�\��Y�\�[��\��њ]�[����YH��Y�S^[�]��[��TY�H�ӛۑ�[�ܙY[�Y�S[�H�\�S�ۙH�������[�ؚ��Hؚ����[�� M�њ[\��ћ]QX��HH������X[B�'/U�[�̈́���(��Pԩ �LVX��d��Bd�6 +,��{R-��c�XMi������Y�iڳN� �����*�����������=���)� �$�-WyxڜI�0[�Ȱ_�b"���U�p�d�e��,5�YT�����s8듨J4�{�/]m��V�,'�MW�{C)�SM��(�]��Țxq� �JU ׄ�e�c�Y�m� �;�R��4�^�u�pd1yy�0]����4�o��Y>/MK>�TX�;2�ZU�Mv�-r�mGW7~��\�7ۣ:˪W;��nV╌�7�*L��qG �랇��8,�¢h��#�?}b>)#�МXK�Q�+����?��9��/�� .�ɐ>�~�f&�;z����#�ɭ|9r�pN����"���M�s�0��{��6�`�S�r]�>ߔ���&4�^s�`{b���w�#"��#5d�;�<.���lA���{��P���b��k�N�5�d�/G�;i���&#(�ӡ$�Z��\�h�"�f�Jƣ��+�n� �W: �^?����Ě���=�ؑ�2d3Ë��I�>�rC��_Cр5�#P��;�5�Q�L#�*O�A�I8v��2c�`]� ���"*F�+�둝L��W�gr�����s�A�7���7枎��o�)����<����Js�[�t��Da�Z�;�^���������+�-�W61���Y��m����6 �[���X[H�[�ؚ��Mؚ����[�� NM��њ[\��ћ]QX��HH������X[B�'U4b��=��M%�F�dEUh-a�4�J�ݮ�8�"L�"M#�2!:�%H�B��-'m�c ��"9#�$ƕH�л� u �L#��eZ��y� Z������}����\}6���c��$�}m���w#Q��FQo�>� ��R�G#�F�`[�����>����L��/1w���VeZ�~��J�a}�w|l�?���p������=&�o>O<���c���W��z�n�a� �#o������АЭ᷄ő�[�?�=(�ׄo�LM^eu3������g�t �h� iK���E�W����`���{#�T�zq� �[ʙm��J71f&ay���b#,���[*��PJ�#���2���*��;�}.AQXF���M�_�0�5�t.܆C�89��]6c�{��D����C���m7��$-�LҨu .�� -�(�zm� �*����B5 Bl J����qzM.|X?z� t#֖2�k � ɴ�c:����&�>��#�+����aM�om�o���u$7�w){����"P�xZ�"k��C��m��b�� �XWXR�C�>�.���r���̺���Aj���i&G+ M�aM�#�E�'[ �?6T>Ɲ �9��}�q�#��J���ឧ��FfV"��\P>j�5#p�!S�v�m���_�� Y�Ѕ�R��w��oo����Cd�Y��Y��扴~ٚ4��] �C[����Ћ��w����'��*}��m�'��ݰ�oA����0]�1��C? �o�w�;�c��O�v?��3%{'���ʪ��ǡ=ΉG��djQ��^/�����A3����L&5}���aDaeai�����7Y�/�K3=�z� s9�oK�e�T}� A��C�xp�_ ����+v#��/q���ŤǼ���ט��#������~K��p��{����Ҹ����aDZ���q=�灓� ~���qך:���՞?�_�Rk�#������{+~\~I~V��alD��A� j�jL�&�z �3n�P�����������������r���o��Po���]�E� \������y ��{ ��m�A�y��K������ʼ�r�Bm��rݬ���d#$V��'�4���������h~W�5�_�����PT�>�Am,C^;\�%��]z�!В�Ї�9� �>u���A�6 �V���-����V�3����G�~_?Ǐ�����K�a����,��C���f$��C~g�f�U��S�&�s=|o�w�Ϙ�Zي�\�%{̑��ݢ�"� vl��'�Q��(&�{�ps�SH<�~L�p�ȏ���F�Ƿ����� �a�/�&E��g�)�)3�-�I�EFV�|�dZy��{�����R(-"�%� ��[[����R� Ȏ�Z�K^#7z�ъ2{�� fd�Q�3_��'�C͘��#��X��P�H��9_8�L�¥/���}{>�����1Z��_8�m&0/��ja�^g�;� �Enި�gQې�l� '����j�Y��� �L��c#�[� �=U�SԾ�4�ZW�Į�Ћ��֏#�|�/m�8$����6�_�'����:}�&�pQ($.�Q�!�zY�(&���h?ݸ �#�A�Ӆ��~����Px�O�Fc��_��5t��f�2��5���L8���P#H$y�p��&�gNTZ �<�l����'dp7u�W�w�E�����'"lj��=�1_��Y��۰�`���M�> ��{-{!{9H&߁+�GZm��� .A��>�K:3FpŠc*h2u��ƁYD�;�`��"����E�7��H� �*t��o�z0��}R�k���^�m�>��l�|d��t���.��g���5� �i�hbh)��jB^xo�au�[Ty;����:/�3��Aޗ�y�A�o�O�?T����^?z��r9X����1����]UYQN�S1�|��#ߧ��ݎG]��X��^#����MZ�T�e�C0JK/4��]�М92 3A��X�����0����z�*�S��P�~Y�"�q��<�hi�0��::ߚZ4%��ɓ�}!�pM���JOU��䴎�>�\ ��xT���zǟ�p�pΡ�ݚ�+pu�z��U�*`U-�n 탱���!�{�*`ѝN����v���B�|,\���'�*4���ɮ�z�8;�4�c��T*�&��Z�О�[�F�3���Z;~�!ٝ�\����f6�s���18oP��e�lgr���u�j�厦mp�"� .ݻZ����T�徊[���/I/�\=^�1y�8y6��w~�)c߂j���Bè�3��7j�$80�y�p�5�����}�8����s-ݴ�(/���-�F���P���%�}6S��I�������4�Ė�p1/?��IUi�LY���)�B����=�|PR選f��f����aڼ����$Qwj���W�t���XK���#����3+�����Mzi'�(/�Gc��إ+L)�1�T���%����4Z�;k-��/����S�,�t�Z����َ��&#��dӖ��+�&e�:��o�L�%/��3wR����c0ō�����+���8&"t龡�{K={fi�b�}YiU-�]J��)EL��D9c?���v�a�S˄}w'�U Xl� ��l�6����T�'7�Qiۊ�l��_���~t��r� �`c&M{V�ZYp�#�WN�:ﭜ�ku{(#��AƢ,�l3��sE}��݃�����D ��D����i�+����G69u�涀�Z��-�HJ&��Tp���R&�tC��t��=g~�!�ik!$<�܆NGè�NT�qE�t��4y�6�v��g,��kW��a����A���?k�N�z�� �Vĥ_ �+�Pm�4y�3��A�h�;J��kh�Q��Oj���a%�vxEB:�.,�d���[�2��A� ���P~�l��>�l��I��<�,���!U���C�_vx��#�0�&�Aɨe�Vb�ҼQ��ʱF�O`�>��y~��#�[����>*�T���R�:p�6AF��n#֝A�:��5Gt*��X�:�����|�%��c凕R�4h��$L�s.h^m������Φr|:D�1��`�D��eT�R�oU��t�JgKiJS��z�Y3���Op����A�������$��s O�� �1�G��s O¼��G�^F��!��=U� �� Ss�?0�4�: "�BF�0ĩ���+�)&�B���S�p�� Dp�xF�!���6�&�� ��|)��*ɞ���0���ED��0\Ĝ���^�V �t3o(.�Qɢiv��u�Oc����2��ӂ2�+���//�A=Z7M!� �۠��Bhd��] oG���w�F�{ ��EaJ���Wn?>x �YO&��6�5�\`�W:�������,̬�l�l���(��uRN�Ml� |��h�#��A��G�.`��%(]34fh^ݡ���n���)��#f�Fϐ��r�vh�k����5�F��q�fn+����KA�/��^���� p`7^�êG���W�L�ݾ���3�n1��O��:*����F�$^�E�w�H�(�?�E�� �����a8�QaЕ ��(�TAW�RrJ�YfT�� �R�d�D�T���}�N%H �Q��R�J�NP�JB� �A#Q�Q��\�)�� �������k�K�ðw ����_�N.�Ϗ���X~�'F7��[��b4�T��uΪU�C�g.���-�t^黙�k����lVO��}L~��v���G�w�go���u�a=�z�K%Z�3�"�50'S�����,3`�-��>�a��-#z�4(��E�K(�YuEvk�9����"����v(�|-�J|W��i��L����[�b��t P��|�B/�QJ�YK�ȜY��Ju٥����iW_�h���pjq��ˡ ��#�#O���H㢀G���-Z1B��,��O�Q�����f���FY:5��RҚn��h6��׀�.� �K�Fp3�iVR�Ҳ�__��"�˯| �|ˆ ����PWbU�-h�z�V�9�G�� �`c�{�������<��+�L�+ww�U�,��L���)%��,e�b�h./F6ex��b��Ӎ#{[F��v�%��Qk*m�a������=���4���r�#�1Ǥ������7�:�of?tu��}a�*������m��Σ����f���,�����������}X+ |Ɉ�����h�jǺ�W�tQ�^�[��Xb���(���7�!��UhYZ�ZcS2���iT���S��XM�-�[q�v[���J���'� �Z ����p��yq�9ܮ�f&!g����T �(��ů���E�3cݮg=]aBӤ��ڡ]��l��j��}[���U��b:{#]%�����LD�bb��FM|��8��{=��� ���0fnV�� ����lg�q��!�WƖh�xC��hZ���"Zܶ.X͐��5��v}�/2�]p$�GK�!bѤ!��G$�1���j~:��mV�l�Yo�����5�� �f>�q���i������x�E~ ���!`�*+��|������pT��Բs�]�y��-����B�� C�K��C��\���'�Ň��0��U����Q���uZ-=����)��xL.�7C���g���g���9j;^����9a�9k��m��ϹO�EC��f�E���?���������Oyv`��3���ʫɺ�F�*��� �KL�go�kZ����_-iti�$n �a~l [F�#��_#�q�NZ6��۵��r��-�G�ö�ݹE8���J���l�C��]�L8�<�2�6�}�~�w6o���5ƺ�m�~�w�dj�S�T�uQ�lЛ��՚u:�),!�eHk���r!ʴ �?�͡E}�c������-�F2��ǰ����`{$��}!��l�蝆l�+�;K�.W8n�oZ�V�lŦ�gmTh �o����g�V%��5g�� ?�ƪҬdq����;����e�~�?(��3�O�Ym�if4&��iv%��z�1�n ���X✋����br �Y84��p#f�0����ܳB�E�9�MW�&1D���"��� ��?�M�?����e��0e�}�S����c�u�9�8}z,t�4�"�љ�V�s��mK�L�m�,�m���-Eh�h������˳:�kk��>�cfqV��B�<&�;����x^p�*���ptz=%w��m��m �/�%����P=��{azgst����y���Rǘ��M)���;�1X�����\��/�جn�%����m��}�� D��j� J�2:Ye���gU�(O$���F��3�Yl�nJۦ�k�"n-��p�������Qt��.i���������:�I�m1or\Gp�۟�?��GY��f��G�#�>5�ǯ��ȶ�|��D t\tq��)�����N��s�\]c#���7!c�� (� M�۽����e�=��mt��Z����<�_JȨdr F���2�S��\��-����"pf<#�m��Wu!�8 HTiA�4Y�`ʚZ�Ju��뾞�I�g�B�60�����#D=8���y�E�RY?�}���#ft���o����w�;����K�^n7�g3�`��YJ�<{z=��oX�5�9G'*��s��Ӹ ��bBr{ؾ�"�D�S�tW�z ����Gu�CN�Y�*�_ �\��D�3c U#!$���W3��Rn�P�K9����]��P�TH�r.��r�:�w�4��Nw#i��b1P�gC��<$)V�B��J����� �T�eOfD�XI�^ ��0h�I�oJ��;���ǝ쓆7oEQ _�ǣ!P��:�U� ���27�)hXT�8��# ] d�i�%;PBx�z�R6��wV�b�� �;�+�����?��z[�u� �?sz�;����p�y��_�~�Q�K�ӈ�~�{KD��j�[v�"}�����E=8���� ft���gJh(J�a��*ZD��Wy`�V;����F) VE�r���h�����|��0�U�ԅQMh�,#�L^Z�#�Q���_�v���7HI�O=�' �>,D�xЎ;P�f?%�]f�$4�e�Z�j�t�|��bT��"|bc�4�1�8a8Rq���]H��W��=Q�- ���s�.� �Xi����g eqd�!�^קb����yV[�3�5[v��/ş{O�G�����_���� �w�娅��\"\�ś�n�+�m����c�n�Ե���M�;�L7�~#�J>%�f�y���t<}�� �*���Ub��4�&e�����3�w. �?���d2?j�6[��{�طÇ�z�o��|���/�.��r�.�)J��?{H?p�?]�f�U���h ?� >���a��$3{�*���Qo$��\�����5Y��R��a2��y�#���y�+�� ��#V�#֜hB42��p:+��D����eB�#�~}/U�w�oz��G;F7�=)���� ���w��'��Fp�ۻ�7�\���etW�~�֑������#�?J�>Ք�w��(�ϦEmx�x��}D�Ge��1>�v��y�ٵw�v���1��.f�:��,����B��9��,u�����0��p�*�[�\�H9��k��������������y3����#B�(��E� ��V�F�H�*�*� e�+���r�I��0MP�������)��u���["��%�mL����nQF�,� ����2Y#�UP�,ȼ�| �������L۾��0�0���v1�xӶT��#�X���]��Zha,���SRڃGA��(.��N���Ntf�(���'���4&��v梈*��4�Do�1��!��C-�Lw2T��[����^ӟ����䧔�~�%�l��R��V>5��ym�XJ�g[ʏ�������}v���w����5��e'�a�ŝyk�o����z�?c���x�~z�M?�y[�T����JooO;�$����?�'�mx���7��:_p����������ҥT� ��Am��"-"�$�7��,#/ 2g�%��J�)�O�F�r ��)u6�z#.D���VU(�A�נ01��������QOI�DIsM�"o�`��`~�։�έ+����꿰�4��R���c����kNۍ�R�_J=1T�C�s��;ؐ8�.#��/tI�ѳ❑3����s���gͩOx5V�o�ђPib|�K����zOaDi���"*����XXÿ��f�c���E~�mJ���f��G?���FY�n����t�Z���=f�D�ܧ�oQ�[O���1d���ݍL��IT�Y�v�'��;R��"���Q�����YV�X�͂��{qo��J����5�����?�lA��ލ���uU��/!c%� ���o_����\'w��Cs�_���g3P�� �;6��koCzџ�&��z�ǯ�;AHe����Sֽ����T/'�>�?�an�H_������+3;�^H7`�#�7xݮÐ�������Ȋ�����G�'�����K)�Ɔ[�+~��~3��l�:���ξ�8��~д��ӻ����-Y 6s�p.�����x���_Go�܋����|3����1Q�� L���;�!��C��7Q�C�S�=;F���D�\�Z�� %tE�i2���)<� X����i�����k�?U%�����j3y�B�����)��2�3_(�q�����;b����Y}�� ^\g���;���`>��:TD�2ƒ\`�[�V���K���{= r�ЮDX����5V�U�r�S3�P������d�b�*=��v�B6�"� -3 �v�?8�2)G��(б[< ��� .T�<^*���"�"&���C���T�V]$�&(�&��p�ۤ�S���Z!a7��$��� �E?#��v3 b��δ̧9+����Tܙ�l�AN��C<�e|ۇ�]r�S�u&*ԧ�gT��������+oy>�y7U���]~h#?����f��6;���ڃ���}��n�9y�a?a�+�����&��/�`�j�M�5�+���5�5��ލ�����5���&��*>����%[�n<�{}�$4>�~UҒ��>��yu��o}����u� �LB�3Nap�9L�N.X'����^E�l��1 b�Q��g�o���/�_��ti���F��s�\�[�˚��L�U��Y��sqʢ�����L�`w`ֆ�U)t�U[��<��:�0kD�h#v��|����7��T�DOC����wxTJ��Ε�J�F�L�o\�JK��[�#�� ?�=%c��!oy?�nU�_���R���������^�C�u���|����$�b��;�'q����^D���好a�>��]�dL$��<�+�Fi oE�3�Gj���k+~S-�����dԼ��K�����ѓTԐ(�֚֚��c[�B���k�)ޜ�e.�CLƹ�Ջ�:k�8���]S�;+{�zk���)�'ʀ�v��0�����f�4T�k)��[\[QSQ�̹vV�XU�y:� jZʵ��[b[#�ҷWV�oz/�:�S�ߪ>-����Ɨm]Cc[]Ad��>`�T���k>�7�_C��cS6��UN�L�Uv2�}��3�T����0������T:�U+|�wਜ�9&������W�RN5(����Q��#�E��z�T��i�{��e(��̀jӳAm���(��-G� E5����kA��T����Kyy�E1N�ŧ�f��.�T�>�� �W 4�gP�?c���A�8$B�T��\���a���y�}mlf�c�5��[5����L�� �U��W���̾+w�����u�$6S ��E#���9G��ɟ��N�6k���;�<"�9�Q���_)gZ2��>K�<���m��r\�P��'�#qa7��g�փ�4�p&�pe|S1�b�c"�V7[ËŦ���H)(b��P{����`<5M�j��q�#Yad�$��,a������%�z�*�om�{F7K���]�N�hzz[J:%u�zB�>��b`J��^�O熀�?���$[Y���R�&W �w�έK�K%�0V4��X�� ��3~wi�#>p�<ԟ�!�<�aGW�2�?�|���Ej��_�ѻ���^�����p��"��kR#e� �x��;�e��#xĶxP�$��v ���J���{��j��dž1�qN}f���I�$�>��u�$q����a\�� ����)�5՝�y.����w��h7GT�^-Ih�c�tX3��O9PkRP�G>��r��+�KU��6�2\B}�_��U��Y��,F�(ųۥR�]y<=��]�1W �8%G�&��N�� dEl�+�R�~]gݲ_^����(#���]�#"��T`zq��$��C|M�� �?M�F`��V�I�|�#?K��1������}D`6g�uCI��H���_I�W E/y�K~�c/���}%���%��'0n�7���)��?���_��ן�"�B����❦ЛyJ��~s���r��7��j�pf;Iµ���J��H`����� �{���`��X�I�����At���{�bI�$j ��fms*9�\�c,֣9�Q�V%r�+K |d7}� �%�/oI�5H�^R��D��MO7���&�u���)/zhb-�-���|�!gK���� ��X�V�gE�gM�u.�T�h>����yYn� F���M��2�p���w���4�4�O� �Ǻ��q66� U!P�!-9/���EYn3�#5����n��_}���)��#�R��%��kCqFR�N�<>VH���OH������D~� G� �C]��+�%�,W��IF�5�QQ (�Ӂk�T���<����K�o��"8��2C�4����A���e�ǝ��:ן|��S�-����^~i��h8��_�����m�v�t�~~a��y~�����u�����-�� 9]�{�N���r]L ��K� �7�V�#�wXT�UeLM!��Q�����<����ٍ�۪o����O�ߺ����w��~�|A��[h=�LTm� n�W%��o70)f��:����6 T{��~�� M��o!������ �sc2�p���Rnr%c�{uL�g�ɜr�\�2;�#8V��\���PʾriWC����*Ʉ�k�,TY��J�61<�� �^^��/v��!$�,塑K�_J �t���e�d��R��N4�MϏZ����m��6�>�Tۓ�pM�t���&�,���ϧ�p|go�,YXͧP�C�;}&f暓 ����>x dۀj�N&O�U���U��N�2��/7�Y�ڍl ��s�7����x�7Գ�!"����ɐ��+���������%O����-�����d}�"�σ�2i�y=�����=^�s�{Mh�N�CW�� q�I�V�[�Ffs��k-Z��&4*^��\��_��,6ꬖχ��L���ىy���n��]VJ���Q)�K�0�7�)�&w�U������|�ʋYos���)���ߟ5�lZ�����?�w�q x�I���w�/��V�j�j�#5�CgEX��S�W8�"���I�1��0(�jS|��V+�Xl��de-T��������B z[ <��L���!��e�%N�/IJ��+Ҭ�'�$M�>:R�T�1�����˺�h��;��}�ܦ4�u#�֓��jYǁ��U���:�m���7,}���c� A����{:��п�����*K�R��`໋1n��Jh�=\nR/�Œ���}1����G>K��;��pA�Y���?�wX4��3�%g�K�v}�Uq��gߺ��κ����pK�俳���:;��#���#�YF�{�7�/z����W?#�x��M���7_n�F�K��(Bkm2h#8�L+�[�vD�e�r� ���HJQj��w`N4��[�f:���c�IB�P���]��2�k��w]�����q���m�&"U��Z�VKLHX� �r�&�7��Z�0�����,lv���#���3Gy�ٱ�>WAJ�������]Uж�L��/D����'B(WX�F�:eS��H��sJۍ�m���.��6�w5{�زa�%O_�ZgLb*�Ò��L7���z] �۬]YQ���]\�9M��L���]�2�5f�Q^4�� �#�� �¡�\�Uj5x�x�!�=�Ҍ`��q+��.2.r�+xѴ�c��v�=��{�O���6�s�жbR�ƶ�C��ۜ�鵩�����=]9f�G�J���|�:)�x\0�9�Q��5�ڨ�*u���6w���z��n��������"z+m����� C�_�Y�z�N;s������N��a�R�����p���R�V�A�a�k7���2�a8����ۍ ������q��! +iŋ��6J{��.��ȑxN��#��;!D��R�v��6�҆�ST=#<�X�D`vw���%���l*eᢣ()=� ���s51sP���^?~jٻ�*N*�3�D���(��zPu��0n"���3�m���,�^���|�� ��5�؝�_P�o��8��_u��G]3������6� }�%p�2�9��s�Q�����9/��s�s�o��m*ޟ]}gtW���7U�w�ѥ��IR���J�$ ך|�U��p%^M���z��E�2�Q#�n7;pϭf���V�zum��B�:�2�ʮ nvY���o��� ���+r�������(͎�.X�H���N���4�T�݀B��(�(��2�o��J}XIeM"���L�Ry§�]7E��Y���"���)zu5Y�& �q���Imi�3%S����-�1�2D�ڽ1Dr�����8�����p����<�}��i6��R��Fi�נ�V�\�Cx�QϽ*�nsS*���P��?�7����Oy���_�:;+�*�ю�����˝K���W;�3]f��f��ߵ������t����ޥ0{mʖ/�h�y-xYb���� ������A�k���X��ǎ[\)#_1≑7�4�1ؤ�±���W��$s���!���3�� "̍u0iD d�g�0<�`��یe�M�������=s�5T�۷�!���}����]�/��v>w�'���zǟY´��A��D ����A8�5մչôñé�a�bbY;}h�Lڛ�h�����J��L���J�:�Y) #7�5�ou�ŗGӬVm�C�I���_vО>� i/K��_�sr&�Mo��MwL&���<�0�呒:�O9�� �&槒S��S��f����-��3a4^#tNwm2m�Q�4�� �m�F4��j�xgd�f�LO�����k�:�tG��1Q�v�D���L���Լ�"d�z�j�it��Hgi�b�|$��d��-�̲0,4qI�곶-���z��*� �Y*�G��jo7�����#�7��N�����]�����-G6/����z�x��?��Ee�6/P��ϥh�+%8ێ��%+Υd�������jv��`�4��c������]Y��K��{e������1�h6�p����� G�ҮΗk�/J�ƻ��\�];\]�Wg�FIΗS�5�b����g�T:S����A6u/�s8^I��)0���ݾ��7������"=xP���KM� �Z�J��}~��Ζ-�g����&�����u��������#�#w�_7�vPê�����ԏ��ע��dҔĩ�c��2E���S;K�fB��M�2������}�p��d`'�>.j ��ܝ��e������bыg4383���� a��f�����h�YkΘ�~!)0�T�_m#��d�7b�)t��,҃���r�R�DaC#��KX��P�E�IfǬ2�x'�(��i�-I%����m��E"�E�U���3�S� �S6�6A�sE��gm�45��p�5�fw���S��1�o������w�8���9�q�;���;u�˷��Y5j����.gk*������nx���0�6Z��Y{{cg˷���l���巜��E�<={`�6#|�P����k �������Z�w�e ��Zs3;y�P��c��y ����MlUR�E�����f�{Uzca�^BGٕM����:�I�{>�+��r�|���`��0J�U�����Ȗ�g������.�*aOF���3��\��A44�����# bNNw��'���2���M�����ȉP�lR*̭fLӲ��5|v��q�����]t���fQy�Ž-�O�S�^K��byg�ɤ��Z�n��>3�t3�c,J&�Q��g1k,�d�ϋTabV�"QQ���_:��)c�s�k�{��u�C�C�O�j�S����Y�f,��H��F�V�]���ǭu����]N[�lm�ze�u��C�'��ַ�f��u/�ĥ]�����_d4Y��7��D��S[�r{#�+ ��B�E8��СЫ�(SyhT)7;K�֮UiU�UQ+Ϊ�>��#\$�)d���z�� ������ݭ��AƬ�z�˿��نg�q����Y ��I-6SM��X0�#�B�J�B�9���B5�.R=6�,�,2�8����:9 ���$� D<$]� �-��k�,u�X���ښ�*��!��(�*lB请��o���u������%ଘqBtZ�v�����GFoyR�]SwSQPܹ4��s�/3� b��Z��6 �8�F�k�6D��p� 778�bX����� ��Y�Nڹޮ�-�ĺ����M���/��N�ѽսҶ�IM�k3��D�Ö�<ӎ�<\��?�� F��-��%01� ����oR�?q�� ��4�r�lջ{[hLy�/~��t^��~�ϯy��Oȫ���*i�<��S����p�����w �Ӂ�=2u�/����4���b�G�O�� c��A��U��:f~eEՌ���z2�c�eJ� ĥ� �;�OU>b�)��w�xsy%��K� ��a���W:�f�-}����������z��"s�j��s5h��/�7���[µB�����t�^� �S�)T��� 1�=(��C rM�a��v!A9>�h#D�XR��e�`[`U���� ������x�8{=h�����z�>�]�P��;n�� 4���'�7�m`~����=X �m�����Ŧ����&�^�[�ڟ%i��N6�eA�}�x%�X�w�0�Q� ���[��9'[����F�&�ݱ�����?��Cצ��j<����V�� uF0�F�ҍY,��fօ�B~��e�%�L�n0���#�i� AlYZ]]����C������� ��ע����8�+�V�J���ˎzs�AUo�yO��T}D.��{��j {[+��a?�qs9�����.��}�3��?�2�-���=ڶ��d���}v<Em����pK����z"w:ͳ������.H��۞�SAK~���|f�Ń�xN���מ�d��_��c�ű>�o��I3Yn|GҎ�+��^ۺ�_hq�~�J��B��5a�-jDښ;�����k�mjj��2�TJ�DK�q� ����'SP�V�'g�l��#y��Y̆RC=�� �U[��"(ޥQ[ׯ}# �䔳R�}��h�Ӈh�+Y�;��͑e���p�]v�z��x�8$�Z����B9as��R�4��$��͔ �"�#�����A��]6��c�ϡW�pi��ݫ�a�Z�?�Wpl�A�����Aɵ��0VU�J{��M�P�. ��靰���m��l�R��^���k�z��7�{E�}�� �z+�QXj���앆�j�AjT,�QG)G��C�An�H&�� ��5Z�*�5bR0�5�=t�������݈�N� w[P;�`���Y��2 7 M�j_*��R����А�M��U�e�i�+�U��/�g[��-o�h����4�~�j{�� ��&���.�AY��� G�Z�)ū0 ���H��Zr�!��3�&N���������\�+��b�F�%TP%�B��;�R^n��� #*S����?׀2�iAD#�ېam��Ftk��7�2�T���.;`��ֆ�3L����ٴ��[������o�7{��֗�I�֯������}�v���Z0�z[ ,�k�뿎=��ͻ����1�{��SO��PG������}jMG#ԓU�P�Do�-Q�Q�B�]Kߔ-E�qs�9��h��m��Uh�����c)�ܮ�8�r�����< gc�쬽�"X�_U�{{n��ZQ�<� �����i���E��Z�+��C�2���zip��36R!�*���h�\��-�pزǣq���va�j=ۜ1wSV~���I�I��NL�U�X�z`&Oh[��������/�C](6�Ɛ���m�+u�D����W^��Fw�Ri��G���t�l����OX��A���]����G�wi^6SP�T&�!��t��( XB0S�e)P�̔� &D���_�tޤ������L't_nΧKV���o����SH������{���?�^���\�S��},}!�I��5�*�W�D�ql];ktt�}�d�r����X��>v�u�����S#�$;�hAݚ+�v{S��dύ�ȳ�"*�#'�Q��tl�-�x�1�,��M���rFo�{��E�(O�])�ԗ&Z���*�7�ݢ�EeK�9CȈ�(��"���l5:Ŀ��"��/�(t �z$6�uU��U��� >j����^,�&z&�!��XM�c1�� 'N��ˤ �bZ�n��00�w)zTvN�e� �]��4����1qH!�¬���钱��,��[�8���R#��=���D���B� �H�A-�Q��N�-ft[�����K���dXpF�� M(��]�1�S����r &����!�g�oo����P�?#ܕg*������[�� ??u3�]�� P�[l�D_-�K��OG�P]�� X�K�o]�L0�� _!I�{cDk���|��B�t�E�W����6�g�ǰ��Ub;k<,P ���f��ʒĢ�htI�;�cL����"��C 5�CF3�I��{���($�]_�.\$�X�9��s�d�W$�n�~��İ�3�� �#\��)J�֠�CkCx0�#�5�����)(�##�0jdR��*R���#1Z9�:�ն�找�]��[��NY$А��Ï�����5lਪ�C���_2�q7��ށ�����ի6!�;>�of�u �ൔ�&�����Q`�qb�?�v�n���,�_�ҝ*M�f���6���o�������2>�M~�Z��b�g��?c��I�J���x�▅�~֤��-�Ï�w��it^y a��1�óJpWL��������0���#��<>A�M�`Rv� �OS� kQx�O# �ȅX�^䊕0x�� ��BE���;V�T١��:���x�B���N0M%fr�4�k�g�V�jv ���j��Y����!Y�S�3�'���rz���$��P�t/n�����E��+L. B�����W˩9[�Q�UԞ�� MP e<$�z �W%K�Z����#�\�(G}1l ~9�1ĝ�l�w�m�G8�����G�O[�f����V9���-�*ձ�6�|2����dh 5 T�����h��L<�)dq��͝��SZ�}$����P��ڎ�p �k:�>�fg��^���>� +n���_0-ӓ�P���G��R��~8����v�"���V��l��0��L�"�0��m���Y�b���7]��G�Z%(���p��w�b������B���3�AXV���G��_���¹�eΈu�c�nn�]'o�R�+)���m=D3?X�1e�����v�afuf������N5e��3� "_q������|�SE��9��Ǝߘ5�yyZ�;s9�Aǯ>4~�}�ٷ�B�����v���퇽�Y�{�F�6R�q*�~�?Qޥ�Q/�o����A�'�4��o��Y4�I�T�f��r�Ҏ��^eh+r0�ҧ(���u����.�a��s0��O�)������K����n���}��?c���4p�:-�CE�)M��R�S�6���)��N�1��8����ڂ���G�T�}��=P`��U�z���ò=*N0h�"��r\����& �[��O�bS�6��{�qiʃ� �AqrXn�ٱ>���1��kt ��m1��UE�R�e���|�"���["��Q1��CT6v���j #Dz���Cn>��ց&�!�q�XX�%ab�gf[�#^���H��n�U��It�Iw�6F�H�����{�.O�n~reRy�>�c����ѶrbL]�=��I��7|��)&�LeMF*�P�H_�f���K+� �Mo��l5Y׃CIj�k��p�N��c#ZBj�o�/ƚ�����19��]�l��H�����2��/E��f���Zi����3��)��.�(�tC���l{l�K���N���n�_a�Y�k�B���A.y�קh���*��U��Q=��+y��+&hY����F��F!��kɇ�R�������K��~�#�0��V�H�K=O�6{#O��U�v�0��k����6j��fym���ꗴ�r��õWV��U��֘���,��`���/�u�z����)ն!O�B1�l� ��]��8g~�Cyim�.�G}z�(7�a7�P�:�J�,�y�lW�F$���sK�j'0>�*h,R����I6v�U�|�~rΧD��9�H�u�� �D��J�=$�o�7ːk��~�`qD�,�_3�H"����f ��*5tq�ދ���>g�0j��_� �^<�y��r��LJ��X]LK���fB,yFб]����Њ�얓kRu�k7����̲�װ����u�tX�a�=��>�i7��vj��v: g#pV��1V��>��ի�"�ig���}ɝ�}��{��a���æӸ�o�}�������_~��1t�5Y[���X[H�[�ؚ���ؚ����\H�Y�\����Y���H����[�H��YYXP������ܛ��� �����[�ؚ���ؚ��� �L� �L�H�[�ؚ��ؚ��� �L� �L�H�[�ؚ���ؚ��������] ���ћ���L�������ؚ�X���[Y�H��������[�ؚ���ؚ������^�[XY�P��[XY�P��[XY�RHH�[�ؚ��ؚ����\H�Y�H��\�[����ԙ\��\��\� �����[��� H�H����[�ؚ��Hؚ����\H�ؚ�X����X�\H�[XY�H�Ә[YH�[Y���[�� �M�H�њ[\��ћ]QX��HH���YM���ZY�L M��К]�\���\ۙ[�����ܔ�X�HL�������X[B�';wtZ��<��$ag%�$�7 �`P���q;���#�az�^����=���d�!7vÆ�81�H�7bGI�-*��M�L��MߔF��UIrR^���:R5om뒸�����y햀0=�����m�ϖ6��z#���>��q&?��x|�N�յ��������u-�wM��4D��_��]��o{�gW���v�8�t��/�N���mHW�����NG����������^��K���������s`�Fx!�<����R���B����t���:8$h���������L����(NL�����U*����K�/Tf�WŐ��ja ߤ�"hLN�-�}ãc'g���Ԕ���}٬⥑�[���(� ��o8�gɾ��'S�TǕ^ˑ�7�#���n~E���oQv�pV����}�����}��5�?�.EnY��q6`L����s��ji��-E����HM���ΰT��R�[���&�h�}��_���ɞ�Y��7>����UGw�����r��L�o� ��fC�mm�4g^�ᜎ3-�����3i����m[��{�}E ��m�v�)]�Ihܘ�æ*��?D1���ʆ��ͯ���?ިT�io����p_]*o���w~ԁ#;1��+�f��[���u�h��a��s�"�Pw���#e��kY��.6;���>��Va��?{�t:&��j���F�u�şqc��N��oI[{��r�4D7���,�hoh�ctآ3���K��{�6��Y��������0���������r�Z��������) F�Ò5�%��m���E�'\wϣ=�&R������/�3�����~��݄��-~�3�ԟN!;�?�kwXh��:F�}���4vu��:Y ��]O1 ���T��{0�]��e7�<Л�0�V��m��Pq\�?�նGd+��?�{�Je�G���_��m��2�Y��W��Z�99�4피�Ɗ���ۆ������``�� :�QKC��ى����-w��h���F��ΛmU;�#����������`.�L��\/�gV���=��? ���}3��*����_�f �:y��)�ד����&[��,�#�J��{ ���w��Ы:����#�F���;���f��Z.xmM����3��Y͎%؆2����L�#^Iy���'�t�_�ql7����������=��ܹT�K�CD�խ��Bj8�_?�N�M'�y��h��k'�'��ꤘ���Ő��������K�q�'����L;;�����e6���z��� ���=��lN��Ow�m���!��x�|0������3.�eN�|�ejNE��{�9't���������������V��M�S!o\�v��RW���v[e���-7�)���%pje�o��L�1����GU������ ����^�����;�x��î-�D�Y�M��֣�&{�,��<]�o&n�#��հ�g�>>�����iֶw��]IgknfF=�|��a1l6�C�k�?rA���錡�P��t�u& ��*&cjR&s?U^ч!��6���wN~�ЎB�[L�t���c�>�S���[��#�#��S�� ����l���:fM�7�L؉��[�����'�g�����bJ��������ܣ'ze��Cr]��s�x���ћ1�Eܤ�ʹnZ�iu=��u �8�G�=�_��d�BXXXS���ϵ�������_O�$�����^����^��fE�/V��4s�m��8[�EN;Y�7��w��h[����=F����?���#?�4����ua&,��T�N$��;Hr�b�|��ԛ%�{�۞d������ܢ#`wl6� �����[��?C������'d�_<�ֲ����<��s�d>�;Ỳ�eU�#F&��p��!s�֎��WS�Le������tS�{�9#g�]�}=��ЖC=U�l����o[n_�t`����f�}^Z��b��2��2�vUϙ`=l�]W{�նɮ��!q�\��2�y�֦��}������M��+�7��^�\��ݤ�{��˝!�Ԯ�������Y#�����y�U V^EƛL�Uz�$���Ԟ3e�x],�p��N������t��3U�z����:�I���]����X,�H��g��ӧCyiN��&���#���j�c���V���G3���r��{���nY��d�בv9td�.��{�ڋ�G��\�yw9�!�>�ӱ��yw]#���X���9}�ܩu�t:U�Mr9�O*.����F���o� �S�CG�q_?��s��S���l܂�����47�D�#���S��G�i�($d*�жj嗏���#��,���|}ٰ����E�sj����Op�u�w ��zi"% ��|�N�J��Tk�suz�}����1����>�ɱ�ၮ��Y�ʕ�27���]i�{�ޙ��3g��%�Y��=�ޜ���)�[Ò���;�{�GƦ�'�X�;�pN�˱;��j�.l�[�-:�}���c���������_-1�ͷ�;RY��ň��pu���Tg����epֲ=��]�'cU���~��d�T��-bz�щ�����Qcp��}���Ų���!}��;����J�˝��}�Yzo����ɐ�9��)�_���(4W�/nN�nz���A���O.\�ϚwC>G��\�u��K�}�G�۟�bq������w_��y���]��כ�$���wRKٜ��/�|�����c��wA��6�˟��xA݈��iƨ[%xnj��g��֫s��%���=��������ڙ���h������s���L��6�˱���L�DL����< �T��pH������QV�R7nݿ{�����x6���./��<����☭�h5�y�6�Q4�����Ѫ�כ�%X��?�O��y�4Lό���pg7����_��_ �\y>:n|�^YBo�ݹ���J澹��?�0:L�r��T��ٺ�{�n�{�3#͈M�������K�N����6�]��*�f��s��0<^VWg���0,�w��� ���ɖ\�7�/]��[Y��pwv���k��#<^�,f[7�o6�������(�����ov�ۛ�le]��;G�7�_է��v�_˱!j���܂��'���q���w65�V�����}������C�{��\�����vVT:[�)���q���%���Os#�1d��#��Dў⧸�$H�_yX�A⨩�����C��N�w�/�����g5�7O����2;�#�M����e���X�9�4d����M���ݏ�#��f�o�'�%S��v��.D�������z���\�l6T'�J���F��L_��Z'��4�=?-����Ѻ�~�;��Lt�5���r-֣����y���o��! �F�H�o�y��m�/�ooϥE�sc�b�}�����/�ɏ���,�U��M��=����˼�?�*�����BT����̆�������*((�?ؗ�8�u�_?6^?��a_5�^Is��.�[��W�]�'�� ��ɗí]������.�k��w�����R�q�!�oJ���$��$T)b�ggmا3���\I1r���J�ê�sy_<<\L��X��0\Mkɍ���9��{�����Nf;g{qN�{���#U�����כ7c8�jXE���:�W7�o7>`��p'���go��3"�S����r�u��qgf8�K���Ջ�e÷���"��rG�j|�j�a���Cb+'W�����ee���n����W��X���Cl��og;��e#�5��`�1R�>�����1z��.'��]����W���1��/���Ćb���� RZ�2c����P��i�E���Ʃ����^n�k\�/q���L��� t�D��0�us����&Yj�(�i��//l�i�e�ykO/z�L�K�T�l6�VM�G>Q� �>[�����Z�^ U�/��r�N �#�����#?���Ir���ܤڏ�r�^9 q����NJ� ��jh}�&W֞^c�o�/~�to��7���8�cq��߁�6u(���o/NMu�\IK�Mt�,ر��մӗ��m&������o��H��Z��9i�m)�+�o�W���T�� ���W�wG���=��#�^ "ì~�^�' ݽd������������cU�G����������_˷���z�^E�i�O �ͻ��ח��f��b���w����gWۡ/�)�GU��Kw��q�ԆK�\�H�܋U�X��N O�\������{��r�O ��e~|�Y�yifT�9����3S��Dž����~����_�a�%�/dv�-n.v��%?X�����;���O��Z��j�]�G0+��]�J��+�������f��0�{8��;�>Ic�����~2��0���F��ש4����������`~q��{ll���qV;�ޙ��gF!�Q��Z��S�\���8�{�h��C�q ��/���S�i^����~b�^�]��뺿j���h��13J�� /ľ��j�ꢘ�{�{��C�����G��nf빰�:�t3�k����x�OK��guԠ���e�����4Q�=R��S�f�I��5�j�M�#�^�=Rδ�4O"ko�1_�d��ۊ�9��گ��o���Z^p��y�N��!q�E3��x����\n��Q��8�Q����h�Y�ۭ:'�Eت9�d���#=Ep�Tz��ds�d��%5s�V�Y�˗�3~`g�>��u$Q�3^��h~Q����ۃ�*hhxxtvo+�ڧO�N�G�����6�����ɰ�yNJ��f�����gҝ^R���#�_#��8�sV�y�Ο�,1]&%w�.|���l,Ÿ��t�����Q�Ɔ��lG��?fSw�>5?7P۸z�]���eU�M�=Z�����˻�#���l�[H�n����ثw&'�3�瞜j����1��s>U�U�����sp��XM�N���b�ǭ؞q=�����C�!��X��k;,n����q�`�5��8}�E���z����]�~^5Ֆ}s�U�L67ЯL�i�c�,yɿ�;m��\�g7^Iw������5��������rf�j����m��W~�N{��M[V�M��Ͳ�ul�-��������v�W���!�߯��X�����j��W�����=�z��iֻ)߯�<�mՕ��V��q��8�����#KC�嶟ϗ ��Ow,��ܿ��O�q����VJ�m|t�������'N}�w�93,oq�%~��~�d�^� ��C����=4�����m����{�iU��墟`\;95��ے��_(�R�i<��}��x`jt}i-]:����R����������������K���� ap��ee��f#�l>B�����8ka��2D|�5�Q�X�ǯ_,�|�,X���>�����:ÿ���Ӌ�_��������q(��܄'Jt����k������t����퓯��l}8la����o�=��ϊ�T%-S�T��j���{%iig˯W-'�+ǽ���I��|�e�R��u>�<�>,={����f�堸Y:S������n�}�|Pj���/?9#�iC������#~P�I�aiiS�Ŏ���yTB�U3��G�O6~�=j^JY��崫��eu��܋'Z/e��&�\)fsכ_fS��|]�?1��fX��zs2a�G���D��Ϟ���eyԯ�zV�C����0��ݔ�|� �ǧ2kd�Be��yQ�ךo>��iX��zviC��z9O����]+�����ǟfr������g֓ϋN����)=uh�����'�&������t>���}�_}Y{� �߽:2U�u�ǩ����k�o��+��+#0~���BV��[���X[B�[�ؚ��Lؚ����[�^Y�]�X�T�Ј�MHLH�H�[�ؚ��LHؚ����[�� �H�њ[\��ћ]QX��HH������X[B�')a����G!���I�}q��u"� ��� 2 ���6k�Y�=���,2�J,������y'T��<�'�sWsݳ�����]˲��������`,^DX#�𛁎�O�6EȾč/���\���x !2~V�8/���\�0u�%����J�O�a.�3�CW9rS�%�'���I��Y�� *�6/i�/mp�B��ZH��.g|;�����ڧ�y�$������|'Pg�ÿ=Z-���i�B �� E���J��`����uu���~��B�pY�-�<B-f9��!V�_$�7����G�$q�.��Q�7�byپ�I.�#|C�b��|Az�����=.��/�sS��=�e-V؋Y��� �F�q������4�� ikb���6:�+�Fvγ��m+E{&���_��'T�E�vQ�m�BW#��E���m��v���gh��B���֜jb��T� F���.C��(��!ǟ����V!ğ葮�:�w�t�~�_�ɷ�y �|Q��%��vklN���O�{u�[Ү��_�%�$L�T&g����oE��[���M� �S�k��&�Y}�Ygɞ�H)��"��S ��Һ��A�I`�q� g9lJO� �sy�6T>g����[k99�����f��[���X[H�[�ؚ��L�ؚ����\Hћ���X�\H��YU\H�И\�Q��PPPPPJ���\�Y\��]��њ\���\�̈��\��\�LM����Y�L���ћ\�ܚ\܈MH����[�X��HM�����[�ؚ��L�ؚ�������������������������������������������������������������������������������������������������������������������������������������������������H�[�ؚ��MHؚ����\Hћ\�ܚ\܈��\��[������\ZY� L��\��[�L��ћY�� �ћ���M���ћ�[YH�PPPPPJ���\�Y\��]���][X�[��H���[U����[R��]���Y ��ћ�[L�M����XY[����X^�Y � ��Z\��[���Y ���ZY�����[�ؚ��M�ؚ���LL��M� ���L�HH�[�ؚ��Nؚ����\�Y�Hܞ\�[ H�[�ؚ��NHؚ��ܞ\�[�\ܝ�H�[�ؚ���ؚ������X�\� ��\�Y�Hܞ\�[ H��ܙX]܈ ܞ\�[�\ܝ�H����[�ؚ���Y���H� �ML�H��M����� �����MH����M�H��NM���̌H����� �����͍H���� M����L������L�͈��̌ ���̌����LL���̍��H��̎L ���NL��̎MH��̎NH���������Z[\�����^�H�H�ԛ��H���[����������\��Y����LM�IQSш��:�g������^��m�g��.���"f�y����{�(j�hw/졪D�����
I'm working on Laravel (v5.7) app that converts uploaded CSV (with contacts) into array that is then passed as argument when job class is being dispatched.
Here is the example of CSV file (format that is supported):
123456,Richard,Smith
654321,John,Doe
Uploaded (CSV) file is handled like this:
$file_path = $request->file_name->store('contacts');
$file = storage_path('app/' . $file_path);
$contactsIterator = $this->getContacts($file);
$contacts = iterator_to_array($contactsIterator); // Array of contacts from uploaded CSV file
protected function getContacts($file)
{
$f = fopen($file, 'r');
while ($line = fgets($f))
{
$row = explode(",", $line);
yield [
'phone' => !empty($row[0]) ? trim($row[0]) : '',
'firstname' => !empty($row[1]) ? trim($row[1]) : '',
'lastname' => !empty($row[2]) ? trim($row[2]) : '',
];
}
}
Finally, $contacts array is passed to a job that is dispatched:
ImportContacts::dispatch($contacts);
This job class looks like this:
public function __construct($contacts)
{
Log::info('ImportContacts#__construct START');
$this->contacts = $contacts;
Log::info('ImportContacts#__construct END');
}
public function handle()
{
Log::info('ImportContacts#handle');
}
... and everything worked fine (no errors) until I've tried with this CSV:
123456,Richardÿ,Smith
654321,John,Doe
Please notice ÿ. So, when I try with this CSV - I get this error exception:
/code_smsto/vendor/laravel/framework/src/Illuminate/Queue/Queue.php | 91 | Unable to JSON encode payload. Error code: 5
... and my log file looks like this:
error local 2019-11-11 17:17:18 /code_smsto/vendor/laravel/framework/src/Illuminate/Queue/Queue.php | 91 | Unable to JSON encode payload. Error code: 5
info local 2019-11-11 17:17:18 ImportContacts#__construct END
info local 2019-11-11 17:17:18 ImportContacts#__construct START
As you can see - handle method was never executed. If I remove ÿ - no errors and handle is executed.
I've tried to solve this, but without success:
Apply utf8_encode:
protected function getContacts($file, $listId)
{
$f = fopen($file, 'r');
while ($line = fgets($f))
{
$row = explode(",", $line);
yield [
'phone' => !empty($row[0]) ? utf8_encode($row[0]) : '',
'firstname' => !empty($row[1]) ? utf8_encode($row[1]) : '',
'lastname' => !empty($row[2]) ? utf8_encode($row[2]) : '',
];
}
}
... and it works (no errors, no matter if there's that ÿ), but then Greek and Cyrillic letters are turned into question marks. For example, this: Εθνικής will become ???????.
I also tried with mb_convert_encoding($row[1], 'utf-8') - and it doesn't turn Greek or Cyrillic letter into question marks, but this ÿ character will become ?.
Move "handling" (converting to array) of uploaded CSV file into #handle method of a Job class worked, but then I was not able to store the data from that array into DB (MongoDB). Please see the update below.
DEBUGGING:
This is what I get from dd($contacts);:
So, it has that "b" where ÿ is. And, after some "googling" I found that this "b" means "binary string", that is, a non unicode string, on which functions operate at the byte level (What does the b in front of string literals do?).
What I understand is this: When dispatching Job class, Laravel tries to "JSON encode" it (passed arguments/data) but it fails because there are binary data (non-unicode strings).
Anyway, I was not able to find a solution (to be able to handle such CSV file with ÿ).
I am using:
Laravel 5.7
PHP 7.1.31-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Aug 7 2019 10:22:48) ( NTS )
Redis powered queues
UPDATE
When I move "handling" (converting to array) of uploaded CSV file into #handle method of a Job class - I don't get this error (Unable to JSON encode payload. Error code: 5), but when I try to store that problematic binary data with ÿ (b"Richardÿ") into MongoDB - it fails. The weird thing is that I don't get any error-exception message in log file, so I put all in try-catch like this:
try {
// Insert data into MongoDB
} catch (Exception $e) {
Log::info($e->getFile());
Log::info($e->getLine());
Log::info($e->getMessage());
}
... and this is the result:
Anyway, I believe that it failed because of b"Richardÿ", and I guess that the solution is in encoding string, but as I've mentioned - I was not able to find a solution that works:
utf8_encode works (no errors, no matter if there's that ÿ), but then Greek and Cyrillic letters are turned into question marks. For example, this: Εθνικής will become ???????
mb_convert_encoding($row[1], 'utf-8') - it doesn't turn Greek or Cyrillic letter into question marks, but this ÿ character will become ?.
iconv('windows-1252', 'UTF-8', $row[1]) - works (no errors, no matter if there's that ÿ), but when there are Greek or Cyrillic letters - it fails (I get this error exception: iconv(): Detected an illegal character in input string)
You have several ways to deal with it but I'd recommend the following two. In both cases, the idea is that you store a UTF-8 string.
A simpler approach, figure out what encoding it is out of the (your) predefined list and convert it to UTF8.
$encoding = mb_detect_encoding($content, 'UTF-8, ISO-8859-1, WINDOWS-1252, WINDOWS-1251', true);
if ($encoding != 'UTF-8') {
$string = iconv($encoding, 'UTF-8//IGNORE', $row[1]);
}
The second approach is to use a third party library outlined in this answer
I have a very long XML composed of articles and I use
$stream = new Stream\File($file, 1024);
$parser = new Parser\StringWalker();
$streamer = new XmlStringStreamer($parser, $stream);
while ($node = $streamer->getNode()) {
$simpleXmlNode = simplexml_load_string($node);
//little debug here
echo (string)$simpleXmlNode->codiceOD;
//
if(isset($simpleXmlNode->gruppo)) {
foreach($simpleXmlNode->gruppo->children() as $child) {
echo ' - ' . ($child);
}
}
echo '<br>';
}
It works very well except for a single line inside an article.
It's Italian language
<datiTecnici><![CDATA[POL<->SCHIENALE. MODULATORE DI SPINTA REGOLABILE. MULTIPOSIZIONATORE DI INCLINAZIONE. RIVESTIMENTO IN PELLE SMERIGLIATA, INTERNO IN SPUGNA HR ALTA DENSITA'. SCOCCA IN FAGGIO MULTISTRATO. BASE IN ALLUMINIO PRESSOFUSO VERNICIATO. BRACCIOLI IN POLIURETANO INTEGRALE CON ANIMA IN ACCIAIO. SEDILE REGOLABILE IN ALTEZZA MEDIANTE PISTONE A GAS (CORSA 10CM). PORTATA MAX 150KG.MISURE: H 117-127CM; L 63CM; P 60CM. (H TERRA<->SEDUTA 44-54CM). 21KG.]]></datiTecnici>
It raises
Warning: simplexml_load_string(): Entity: line 62: parser error : Extra content at the end of the document in /web/htdocs/www.site.net/home/import/iterator.php on line 81
Warning: simplexml_load_string(): in /web/htdocs/www.site.net/home/import/iterator.php on line 81
Warning: simplexml_load_string(): ^ in /web/htdocs/www.site.net/home/import/iterator.php on line 81
Notice: Trying to get property 'codiceOD' of non-object in /web/htdocs/www.site.net/home/import/iterator.php on line 82
Then stops.
I noticed that it has something to do with the length of the content inside CDATA. In fact it works fine if I cut the string a little (don't know how much yet).
What can I do?
I """solved""" it by splitting the big xml into much smaller xmls.
I don't know why it works now
I'm using twitter api to retrieve fav tweets, then parse them using a template:
$favs_list = $this->connection->get('favorites/list');
$data_to_parse['fav_list'] = $fav_list;
$html = $this->parser->parse('templates/tweet_list', $data_to_parse, TRUE);
$output['html'] = $html;
$this->load->view('read', $output);
the template tweet_list is simply:
<h3>Favs:</h3>
{fav_list}
<h5>{text}</h5>
{/fav_list}
But I keep getting these two error, and repeated multiple times:
A PHP Error was encountered
Severity: 4096
Message: Object of class stdClass could not be converted to string
Filename: libraries/Parser.php
Line Number: 143
A PHP Error was encountered
Severity: Notice
Message: Object of class stdClass to string conversion
Filename: libraries/Parser.php
Line Number: 143
The weird thing is that, under these errors, my html is shown in correct format.
Any idea on what caused this?
I don't know optimal method but I do usually with
json_decode(json_encode ($favs_list), true);
You are trying to print out favs_list but the content is an object, and its having a hard time trying to convert that object.
Just convert the object to an array instead and use accordingly
$array = (array) $object;
in your case
$favs_list = $this->connection->get('favorites/list');
$data_to_parse['fav_list'] = (array) $fav_list;
I'm trying to load an Excel file from a certain source with PHPExcel. I have no control over how these Excel files are generated and they need to be opened automatically with PHPExcel without human interaction (re-saving the file, etc).
I'm getting the following error:
Fatal error: Uncaught exception 'Exception' with message 'Invalid character found in sheet title' in C:\path\to\PHPExcel\Worksheet.php on line 418
The error is occurring on the load() line, using the following code to open the file:
$reader = PHPExcel_IOFactory::createReader('Excel5');
$excel = $reader->load($filename_xls);
The sheet title is irrelevant to us, so is it possible to just ignore it? Thus ignoring the error?
You don't really need to hack the core, just add this in your own code:
// $invalidCharacters = array('*', ':', '/', '\\', '?', '[', ']');
$invalidCharacters = $worksheet->getInvalidCharacters();
$title = str_replace($invalidCharacters, '', $title);
Worksheet.php exposes getInvalidCharacters() public function you can use. or get lazy and use the array() directly (copy&paste from Workbook.php definitions)
We've just done this to get it sorted for now. It's probably horribly bad and I wouldn't really advise other people doing it, but hey, it should work for us!
On version 1.7.8 of PHPExcel, in /Classes/PHPExcel/Worksheet.php around line 414 - swap the checkSheetTitle() function for the following:
private static function _checkSheetTitle($pValue)
{
// Some of the printable ASCII characters are invalid: * : / \ ? [ ]
if (str_replace(self::$_invalidCharacters, '', $pValue) !== $pValue) {
//throw new Exception('Invalid character found in sheet title');
//Hack to remove bad characters from sheet name instead of throwing an exception
return str_replace(self::$_invalidCharacters, '', $pValue);
}
// Maximum 31 characters allowed for sheet title
if (PHPExcel_Shared_String::CountCharacters($pValue) > 31) {
throw new Exception('Maximum 31 characters allowed in sheet title.');
}
return $pValue;
}
You may passing special character at title. Please check the text before passing it it to title.
$sheet2->setTitle($sub_menu_title);