edgarasNF
(Edgaras)
Décembre 19, 2022, 8:13
1
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:
In Application Config >> Technical maintenance >> Imports >> Press on + to add new import
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>
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:
Is this the correct way of importing cities?
Are there any other alternatives how can Cities be imported into Axelor?
PakMax
Décembre 19, 2022, 11:18
2
Hello
This post might help you:
hello,
You can import it from the Geonames. Check the datas on the download page https://download.geonames.org/export/zip/
In the ERP, you can select the Geonames archive and load it from the City grid view.
Regards
Regards
edgarasNF
(Edgaras)
Décembre 19, 2022, 11:38
3
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.
PHPierre
(Pierre Mayeux)
Décembre 19, 2022, 1:05
4
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 ?
PHPierre
(Pierre Mayeux)
Décembre 19, 2022, 1:55
6
Here is the standard tree of Axelor module for importing csv file :
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 !
bDurtaut
(Durtaut)
Décembre 19, 2022, 2:44
8
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
edgarasNF
(Edgaras)
Décembre 19, 2022, 3:01
9
This seems to be what we were looking for.
Thank you for your response.
PHPierre
(Pierre Mayeux)
Décembre 19, 2022, 3:04
10
No problem, axelor documentation is not easy to read because something missed examples or details.
have a good day
bDurtaut
(Durtaut)
Décembre 20, 2022, 3:23
11
bind to=importId column=id/> Sorry i don t have see this line
system
(system)
A fermé ce sujet ()
Janvier 19, 2023, 3:24
12
Ce sujet a été automatiquement fermé après 30 jours. Aucune réponse n’est permise dorénavant.