Export UTF8 rows broken

  • Posts: 171
  • Thank you received: 9
8 years 7 months ago #235004

-- HikaShop version -- : 2.6.1

Hello!

I attach you a CSV that is exported from our database.
We have 2 problems, that whatever we try, we unable to solve. We need help!

1.) When CSV is exported from admin's product list, and then if I open it in Excel without using Excel's "Import data from text" function, the rows are not broken, but the chars are not friendly (see attachment: csv_excel_utf8_01.jpg). If I use Excel's import data from text function, and load the CSV to the table while setting it is UTF8, the chars seems OK, but sometimes (not always) the rows are broken (see attachment: csv_excel_utf8_02.jpg). Not always, but in some cases. What can cause it? How should I solve that?

2.) When exporting, the product quantity field can be 0 (zero). But when I open it in Excel there's no zero in that case, just blank field. And if I forgot to change back it to 0 when it's blank, than when I'm importing the CSV to products, those products show as we have them unlimited on stock.

Help would be really appreciated!

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
8 years 7 months ago #235014

Hi,

1. Your CSV appears just fine on my end when I open it with libreoffice:
take.ms/bBcNl
So it's not related to HikaShop but to the way you're opening it in Excel.
The solution depends on the version of Excel you're using...
superuser.com/questions/407082/easiest-w...with-commas-in-excel
superuser.com/questions/911369/change-de...ng-of-excel-to-utf-8

The simplest though is to use libreoffice. It's free, doesn't have all the unnecessary features of Excel for handling CSVs, and has a nice wizard which lets you select the encoding and the separator when you open a CSV:
take.ms/mtmbl

2. Change the line:

if( is_numeric($value) && (preg_match('[^0-9]',$value) || ltrim($value, '0') === (string)$value)) {
to:
if( is_numeric($value) && (preg_match('[^0-9]',$value) || ltrim($value, '0') === (string)$value) || '0' === (string)$value) {
in the file administrator/components/com_hikashop/helpers/spreadsheet.php and that should fix the problem.

The following user(s) said Thank You: pepecortez

Please Log in or Create an account to join the conversation.

  • Posts: 171
  • Thank you received: 9
8 years 7 months ago #235090

Thank you Nicolas!

I've never heard about LibreOffice before, but it's really opening the file correctly.
Also the 0 quantity problem is solved.
Thanks again!

Please Log in or Create an account to join the conversation.

  • Posts: 171
  • Thank you received: 9
8 years 7 months ago #235382

Dear Nicolas,
Is there any option - at least modification in the code - to stop exporting the categories in the first rows when making product export?
We do not need it, it's just confusing as we have to scroll every time more then a hundred lines in the CSV.

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
8 years 7 months ago #235403

Hi,

Instead of doing an export via the "export" button, you can use an action "export CSV file" of a mass action via the menu System>Mass actions to generate a CSV without categories. You can even select only the columns you want in the CSV.

The following user(s) said Thank You: pepecortez

Please Log in or Create an account to join the conversation.

  • Posts: 171
  • Thank you received: 9
8 years 7 months ago #235851

nicolas wrote: Hi,

Instead of doing an export via the "export" button, you can use an action "export CSV file" of a mass action via the menu System>Mass actions to generate a CSV without categories. You can even select only the columns you want in the CSV.


If I use it that way, am I able to import the products in Products > Import to refresh the data as well if I export just some specified columns?

Last edit: 8 years 7 months ago by pepecortez.

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
8 years 7 months ago #235869

Yes. The only requirement is that you export the "product_code column so that the import can link the products in the CSV with the products in the database. And if you have variants, you also need the product_parent_id and the characteristic(s) column(s).

The following user(s) said Thank You: pepecortez

Please Log in or Create an account to join the conversation.

Time to create page: 0.064 seconds
Powered by Kunena Forum