import into site DB

Hotsoli's profile image Hotsoli posted 6 months ago in Import/Export Permalink

Hello. I ran into an import problem. I connected to the site database, everything reads well. I uploaded the data to csv, worked with it in excel, and want to import it from the csv file into my site database. But when importing, only 5 new rows are imported, and no more. Moreover, if there are more than 20 new lines, then only 1 is imported. I tried to export to a new csv file and, without processing this file, import back from it, and I only had 2 lines left out of all hundreds. If anything, I work with webasyst, and the database is from there.

ansgar's profile image ansgar posted 6 months ago Permalink

Do not edit your data with Excel. Use the built-in grids to edit your data. You risk losing data with such an export-edit-import process.

However, when importing CSV files, you likely defined the wrong control characters in the import dialog. I think these would be correct if you import a CSV file produced by Excel:

Description

And then again, the character encoding is important. Older Excel versions used ANSI encoding, newer ones use UTF-8. So be warned.

Hotsoli's profile image Hotsoli posted 6 months ago Permalink

I originally had the same "control character" as in the screenshot. and now they are the same . As for the import - in fact, I did not change the settings at all, but simply specified the file from which to export. I can't change the character encoding - if there is a "method" in the "server parses content" mode, I can change the encoding, but I can't import to the site in the database myself. And if there is a "client parses content" mode, I can import into the database to the site, but I can't change the encoding.

Do not edit your data with Excel. Use the built-in grids to edit your data. You risk losing data with such an export-edit-import process.

However, when importing CSV files, you likely defined the wrong control characters in the import dialog. I think these would be correct if you import a CSV file produced by Excel:

Description

And then again, the character encoding is important. Older Excel versions used ANSI encoding, newer ones use UTF-8. So be warned.

ansgar's profile image ansgar posted 6 months ago Permalink

You have to set the encoding when you select a CSV file from your disk:

Description

Hotsoli's profile image Hotsoli posted 6 months ago Permalink

yes, I tried to do as in your screenshot, using -8 and several others. But in any case, something does not work.. and he does not write any problems in the log...

You have to set the encoding when you select a CSV file from your disk:

Description

I forgot to say in the last comment. there is also one more thing - even if I didn't use excel, but just exported and imported it back, then it broke everything.

ansgar's profile image ansgar posted 6 months ago Permalink

That's why I meant you should use the built-in grid to edit your data. Excel itself may not be the problem, but the fact that you export data and expect them to be at the right place after importing them.

TTSneko's profile image TTSneko posted 6 months ago Permalink

Whatever people do when encountering such a problem is to MANUALLY check their CSV data; do NOT rely on crap like Excel for this! It has a decade-old history on injecting quote nonsense, leading to an inconsistent mix of single and double quotes escaping data, literally """'"test1""'","test2'" and such. I do not care what Microsoft-paid white knights tell you, its a plain fact that Excel sucks at this job.

Take a good TXT editor, e.g free Notepad++ (if you need something running natively on both WIN and LINUX, try something like free Geany). Check all separators and delimiters, at the same time making sure that the CSV file itself is correctly encoded according to the target database. Excel sometimes screws up Win437/Win1252 and UTF-8 even if the original document was correctly coded. Also test your database to make sure its content is correctly localized as previous data could have resulted in inconsistent encoding across elements.

Hold in mind that UTF-8 is not a rock solid set array of characters, especially not when used in databases. "Your" UTF-8 may not be the UTF-8 your databse uses, see "collations", etc., hence great care has to be applied when trying to prevent mucking up your data with nonsense like Excel.

Please login to leave a reply, or register at first.