City import

Hello,

How to import cities database? We are using World Cities Database | Simplemaps.com Basic database downloaded as .csv file.

We tried doing the following:

  1. In Application Config >> Technical maintenance >> Imports >> Press on + to add new import
  2. Select Binding file:
<csv-inputs xmlns="http://axelor.com/xml/ns/data-import"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="http://axelor.com/xml/ns/data-import http://axelor.com/xml/ns/data-import/data-import_5.4.xsd">

    <input file="worldcities.csv" separator=";" type="com.axelor.apps.base.db.City" search="self.importId = :id">
      <bind to="country" column="iso2" search="self.alpha2Code =:iso2"/>
      <bind to="name" column="city_ascii"/>
      <bind to="importId" column="id"/>
    </input>

</csv-inputs>
  1. Select Data file (example of first few rows):
"city";"city_ascii";"lat";"lng";"country";"iso2";"iso3";"admin_name";"capital";"population";"id"
"Tokyo";"Tokyo";"35.6839";"139.7744";"Japan";"JP";"JPN";"Tōkyō";"primary";"39105000";"1392685764"
"Jakarta";"Jakarta";"-6.2146";"106.8451";"Indonesia";"ID";"IDN";"Jakarta";"primary";"35362000";"1360771077"
"Delhi";"Delhi";"28.6667";"77.2167";"India";"IN";"IND";"Delhi";"admin";"31870000";"1356872604"

Neither Binding file nor Data file is accepted by the Import, it gives no error.

Trying to press Import button shows error:

The following fields are invalid:

  • Binding file
  • Data file

Is this the correct way of importing cities?
Are there any other alternatives how can Cities be imported into Axelor?

Hello

This post might help you:

Regards

Hello, thank you for your reply.

I have seen that post, but Geonames does not provide all required cities.

We have found another database that does provide all required cities, but we are unable to import it as explained in the previous post.

If you use xml file csv-inputs and csv import, theses data are loaded only when you install the module. Not with an Axelor tools

Hello Egaras,

I have recently encountered the same issue with data import. I still can’t solve it.

PHPierre, I am using a csv-config file in which I placed my csv-inputs but it doesn’t work. I still can’t see the cities imported in my database. I didn’t find any documentation about where to put the csv-config file in the project, the problem may be that this file is not correctly placed ? Or maybe it’s because the csv file is misplaced too…

Egaras, I am guessing that you’re trying to import your data directly from the app ? Not from the source code of your project ?

Here is the standard tree of Axelor module for importing csv file :
image

You put all your csv in the input folder.
Your file with the csv-inputs should be inside the input-config.xml.
After, you need to install reinstall everytime your module because input-config file is only read when you are installing a module.

I hope this can help you. If your data are false, you can see logs during this moment.

1 « J'aime »

Thanks for your answer I will check that !

In tout csv you have a column id . Replace it par import id . Never make a column id , its auto generated by data base server on the insert statements

This seems to be what we were looking for.

Thank you for your response.

No problem, axelor documentation is not easy to read because something missed examples or details.
have a good day

bind to=importId column=id/> Sorry i don t have see this line

Ce sujet a été automatiquement fermé après 30 jours. Aucune réponse n’est permise dorénavant.