When we import data to the small program cloud development database, using JSON is a perfect way to avoid garbled code problems, but if it is a large amount of data, editing data is more troublesome, it does not look very beautiful. So the best way is to edit it in Excel, and then batch import it into the mini program database.
However, the data we import into the applet database is currently only supported in CSV and JSON formats.If we want to import data from Excel, we have to convert Excel to CSV. It’s a simple step
First, import excel data to the small program database
First of all, let’s create a new Excel and write our own data. The following figureThen start editing the data
1-1. Precautions
1, the first line is the name of your field in the database 2, and the second line is the actual data
Since all data in our database has corresponding field names, the field names should be placed in the first line, as shown in the red box below
1-2. Edit excel data
As shown in the figure above, if we have three fields in the product data table: _id,name, and price, the first row must be from the database, preferably in Pinyin or English.
1-3. Convert Excel to CSV format
Click on the file in the upper left corner of ExcelThen click Save asWhen saving as, select CVS UTF-8(comma separated)So we can convert Excel to CSV format, is not very simple
1-4. Import CSV to the cloud development database
After editing the data in CSV format above, you can import it into the databaseSelect the program stone.csv from the previous stepThen wait for the import to completeThe import effect is shown belowHere our Excel data can be successfully imported into the mini program cloud development database.
Two, small program exported CSV garbled problem solved
We can also directly export the data from the applet database to Excel, but the same problem is that the applet database can only export data to JSON or CSV.In fact, the same principle, we first exported to CSV, and then converted to Excel can be
2-1. Export the collection data to CSV
However, there is a problem, that is, when exporting the CSV, you must fill in the fields to export.Here I want to import the three fields in the red box above and fill them in as shown below. Remember to use commas (,) to separate themThe following figure is the data we exportedBut there was a problem when the data was opened
2-2: Solve the CSV garbled code problem
As shown in the figure below, Chinese garbled characters will appear after the EXPORTED CSV data is opened.This problem can be solved. 1. Right-click the exported CSV file and open it with Notepad2. When notepad is open, click File — to save as3. Change the encoding format to ANSIOpen again can see the garbled problem solvedIf you want to append or modify data to the exported data, just repeat the first step of converting Excel to CSV format.
From here we can happily import Excel to the small program database and the small program database export to Excel.
Feel good can pay attention to stone elder brother, will give you more and better small program tutorial.