Importing Entries Using a Text File
Since the database module was introduced, I have periodically tried, on several versions of moodle, over the course of about one year, to import entries into the database using a text file. It has never worked, and I have usually asked a few questions and then ended up giving up on it. I have tried every conveivable combination of CSV including enclosed, unenclosed, simple comma separation, and even copied the example in the help file but nothing has worked. I therefore have the following questions.
1) Has anybody on here ever successfully imported a text file into a database using moodle?
2) If so, what was the file encoding (Unicode?, UTF-8, . . . ) and exact format of the file (comma separation? enclosed?).
3) Did the successfully imported file simply contain English? If so, has anybody imported a file other than English (my files contain Japanese and English).
4) Have most people, as I suspect, ended up bypassing this function and ended up inserting the entries directly into the database via php admin or some similar approach?
Regards,
James Phillips
Re: Importing Entries Using a Text File
http://moodle.org/mod/forum/discuss.php?d=46048
Re: Importing Entries Using a Text File
James
Back in August I modded import.php because it called certain functions incorrectly. The changes I made enabled me to import using csv. One other user also reported that the changes worked for them as well.
I'm a bit out of touch with changes to the db module so I dont know if the modified script will still work, but its worth a try.
The script is attached in the AUGUST thread.
Rich
Re: Importing Entries Using a Text File
Has this problem been fixed in current version?
I am experiencing same trouble with Hebrew text and have struggled with various attempts/combinations to save from Excel and google docs, Unicode, UTF-8.
Sometimes I get the file uploaded but Hebrew text fields imported as blanks, sometimes I get this error message: The following fields in your file are not known in this database: 'Title'. Title is the first field name however in the DB...
Is this a known bug?
Re: Importing Entries Using a Text File
Re: Importing Entries Using a Text File
I have now also tried with Open Office and also get same errors.
Re: Importing Entries Using a Text File
Re: Importing Entries Using a Text File
Re: Importing Entries Using a Text File
I converted the file to UNIX format and attached it. Please try again with that file.
hth
Frank
Re: Importing Entries Using a Text File
I tried with your file and this is what I got:
The following fields in your file are not known in this database: 'after {content: "fieldset";}Title'
I did send it save the file to my windows PC on the way as it is my PC and uploaded to the Linux system of the moodle server, but I don't think it should make any difference, should it - i did not open or edit the file on my windows before trying to upload it.
Re: Importing Entries Using a Text File
Or did you create the database with an external application?
Database module FAQ and Import and export FAQ might provide further information.
hth
Frank
Re: Importing Entries Using a Text File
I did also export and used the exported file to add the content to the fields.
Can this not be a bug? Can we not submit it on the tracker for solution?
And another note - can we not aspire that the database import can handle upload from windows PCs as well?
Re: Importing Entries Using a Text File
http://moodle.org/mod/forum/search.php?search=forumid%3A587+subject%3Adatabase+subject%3Aimport+-Re%3A+-MySQL&id=5
Especially http://moodle.org/mod/forum/discuss.php?d=46048 looks promising.
And there are already some (8) issues in the tracker:
http://tracker.moodle.org/secure/IssueNavigator.jspa?reset=true&&query=database+AND+import+AND+activity&summary=true&sorter/field=summary&sorter/order=ASC
Please have a look, whether your problem is among them. I haven't used database import/export myself yet, but will do some testing.
שלום
Frank
Re: Importing Entries Using a Text File - UTF-8 without BOM
In the attachment you find:
1. your original file, saved in UTF-8 encoding without BOM (DOS/Windows line endings, so that was a false alarm)
2. the re-exported database entries (importing this again also worked)
3. a screenshot of an entry, (there seems to be some problem with the quotes, though, try leaving them out)
hth
Frank
Re: Importing Entries Using a Text File - UTF-8 without BOM
Re: Importing Entries Using a Text File
Frank
Re: Importing Entries Using a Text File
I did another attempt and was able to succeed on another PC. I used Open Office calc and this time it was on Windows XP rather than Vista on my other machine.
I started by exporting the fields from the databse, then opened the csv file in Calc, pasted the content of the fields, and saved as CSV, UTF-8 encoding. And it finally worked.
Thanks for the help.
I still think it would be helpful to be able to import non-English text without all this nueances and hassle from other platforms as well...
Re: Importing Entries Using a Text File
This is a vast field and I think I will better write something about it in Moodle Docs.
For the time being see Category:UTF-8.
Cheers,
Frank
Re: Importing Entries Using a Text File
Re: Importing Entries Using a Text File
See UTF-8 and BOM on Moodle Docs and the forum discussion on "Beware of the BOM" for further information on this subject.