joomlaboat / custom-tables

The Custom Tables extension allows you to create, manage, and display custom data on your Joomla site. It is helpful if you need to display data that is not part of the standard Joomla content structure. For example, you could use this extension to create a custom table for product information, customer data, or any other type of data that you need to display on your site. The Custom Tables is the CRUD solution for Joomla 3.x and 4.x - CREATE, READ, UPDATE and DELETE. You can add tables, fields, and layouts to create catalogs, forms, or details pages. It has 40 Field Types: Integer (numbers), Decimal, Text String, Time, Email, Color, Image, File, User, Language, etc.
https://joomlaboat.com/custom-tables
GNU General Public License v2.0
35 stars 11 forks source link

error message from html.importcsv when trying to upload a file #70

Closed b1r63r closed 3 months ago

b1r63r commented 6 months ago

Describe the bug When trying to upload a csv file I get a popup saying "Response is not JSON:" and the beginning of a HTML page dumped as text.

To Reproduce Steps to reproduce the behavior:

  1. Go to a "Simple Catalog" layout where I have added \<div style="float:left;">{{ html.importcsv() }}\</div>
  2. Click on 'Upload'
  3. Select a CSV file
  4. See error

Expected behavior See my CSV data entered into the table, or some message explaining if there is a problem with my data.

Desktop (please complete the following information):

Additional context Joomla version: 5.0.1 I did my first install of Joomla 3 days ago, so I am a complete n00b on the platform and may be doing something wrong...

b1r63r commented 6 months ago

I got around the issue for now by using csvsql to upload my csv data directly to the database

joomlaboat commented 6 months ago

Hello Birger,

Can you please show me the content of your CSV file? I tried and everything works.

Also, what is the error message you see? Can you enable Debug mode to see where the error comes from?

dkchick commented 6 months ago

Thanks b1r63. I spent 3 days off-and-on trying to solve this issue so that I didn't have to re-enter 170 records. I also had to add a "published" field with an entry of "1" to all records of my table using google sheets in order to provide the necessary number of form fields in the uplinked file. I assume this field was being hidden but added due to my publishing the table on my site. It was not being included in the custom tables export.

b1r63r commented 6 months ago

I have now transferred the site to production so I am quite busy following up any snags there. I could certainly go back to the pi i developed on and try to remove everything and reload unless the one peculiar thing I see is the problem. The CSV was exported from another mysql base and edited manually. I did not notice that in that export one of the textfields was quoted in double quotes while the others were not. There were both quoted and unquoted text fields containing spaces.

For anyone who may need it, For csvsql I changed the header names in my csv file to the ones seen in the database (es_ prefix) and used a command like this csvsql --db mysql+mysqlconnector://\<mariadb ip>/bitnami_joomla --no-create --insert jos_customtables_table_baat.csv I used the bitnami docker_compose to bring up my dev environment, hence the "odd" database name.

joomlaboat commented 6 months ago

CSV file has to have column names the same as in Custom Tables - Table - Field Title of Field Name.

The number of fields or its order is not important.

The most common problem is char encoding, make sure that it is UTF-8

dkchick commented 6 months ago

I should have made it clear that I found it necessary to add the "published" column in order to uplink directly to the database using phpMyAdmin. I was never able to uplink the csv file downlinked using the downlink button on my ccorch.net domain to my new ccorch.org domain despite using the uplink button on an identically structured table with identical names on ccorch.org. I just assumed the encoding was correct and never checked it. However after creating the identical table using phpMyAdmin on ccorch.org everything seems to be working fine.

joomlaboat commented 6 months ago

I found that there was a problem saving the Time Field type value from the CSV file as it needed to be converted from H:i:m to seconds and ticks.

Fixed:

https://github.com/joomlaboat/custom-tables

If I could see an example of your CSV file then I could probably find the bug or a problem.

b1r63r commented 6 months ago

For the attempts where I used the import function in custom tables my header names in the csv file were consistent with the naming. I simpy added one yacht to the database manually, downloaded it to get the correct format, and then added the rest of the yachts in the club manually. The sample below is from after I altered the names to those used at mariadb level where all fields seemed to be prefixed with "es_" compared to what I see in custom tables. These prefixed names were of course needed to import directly to mariadb using csvsql

es_navn,es_type,es_plass,es_regnr,es_aar,es_sted,es_materiale,es_vekt,es_loa,es_lod,es_lwl,es_bredde,es_dybde,es_hoyde,es_forsikring,es_historie,es_bilde,es_vhfkall,es_vhfmssi,es_mmerke,es_mmodell,es_maar,es_meffekt,es_ptype,es_pblad,es_pdiam,es_pstig,es_rtype,es_antseil,es_areal,es_klr,es_kontakt
Samplename,Listaskøyte,"Sample, Bøye 5",Reg123,1954,,Furu på eikespant,12.50,12.00,10.67,10.67,,1.50,12.00,InsuranceSample,Bygget som lastebåt.  Ombygd til fritidsbåt ved 1984-1987.,,XX1234,1234567890,Sabb Ford,,1970,164,Fast,3,22.00,22.00,Gaffelrigg,3,,,
joomlaboat commented 6 months ago

The first thing I see is that column name needs to be Custom Tables style not the real MySQL field names:

navn,type,plass,regnr,aar,sted,materiale,vekt,loa,lod,lwl,bredde,dybde,hoyde,forsikring,historie,bilde,vhfkall,vhfmssi,mmerke,mmodell,maar,meffekt,ptype,pblad,pdiam,pstig,rtype,antseil,areal,klr,kontakt Samplename,Listaskøyte,"Sample, Bøye 5",Reg123,1954,,Furu på eikespant,12.50,12.00,10.67,10.67,,1.50,12.00,InsuranceSample,Bygget som lastebåt. Ombygd til fritidsbåt ved 1984-1987.,,XX1234,1234567890,Sabb Ford,,1970,164,Fast,3,22.00,22.00,Gaffelrigg,3,,,

The second, what could break the import is Unicode chars like "å".

P.S. It could be nice to make Custom Tables understand real MySQL field names as well in the future version.

b1r63r commented 6 months ago

Yes, when I tried to import using custom tables the column names were correct (i entered one boat, exported and then modified that file). The column names in my sample above were from after I modified the file for direct import using csvsql. The norwegian characters are in UTF-8 encoding.

dkchick commented 6 months ago

FYI, Here are my files. I do notice that the dates are not in what I thought was the required YYYY-MM-DD format but I was assuming that the component would export to a file directly compatible with its own import file requirements. My relocated table is working fine but here are my outputs in csv and json, and my layout and fields.
All Performances by date.csv All Performances by date.json All Performances Fields All Performances Layout.html.pdf

joomlaboat commented 4 months ago

Is it all good now?