ankidroid / Anki-Android

AnkiDroid: Anki flashcards on Android. Your secret trick to achieve superhuman information retention.
GNU General Public License v3.0
8.44k stars 2.19k forks source link

Import from all formats supported by Anki Desktop #3517

Closed hssm closed 1 year ago

hssm commented 9 years ago

Originally reported on Google Code with ID 2631

Currently Anki Desktop supports importing directly from the following formats:

Text separated by tabs or semicolons
Mnemosyne 2.0 deck (*.db)
Supermemo XML export (*.xml)
Pauker 1.8 Lesson (*.pau.gz)

These files (and therefore any format which can be first exported to plain text) can
therefore be imported indirectly by AnkiDroid using the sync feature (https://ankidroid.org/docs/manual.html#AnkiDesktop),
however some people without a computer may find it useful to be able to import these
directly into AnkiDroid.

Reported by perceptualchaos2 on 2015-06-02 06:15:19


hssm commented 9 years ago

Reported by perceptualchaos2 on 2015-06-02 06:16:32

hssm commented 9 years ago
Issue 946 has been merged into this issue.

Reported by perceptualchaos2 on 2015-06-02 06:16:55

hssm commented 9 years ago
Issue 947 has been merged into this issue.

Reported by perceptualchaos2 on 2015-06-02 06:17:04

hssm commented 9 years ago
Issue 948 has been merged into this issue.

Reported by perceptualchaos2 on 2015-06-02 06:17:13

hssm commented 9 years ago
Issue 994 has been merged into this issue.

Reported by perceptualchaos2 on 2015-06-02 06:18:43

hssm commented 9 years ago
Issue 1010 has been merged into this issue.

Reported by perceptualchaos2 on 2015-06-02 06:19:30

vi commented 8 years ago

Implemented import from simple text files as a separate app: https://github.com/vi/AnkiImporter

Not everything from the respective Anki Desktop's feature is implemented although.

hssm commented 8 years ago

I'm doing a bit of a rework of our import code at the moment. While I had no intention of porting the CSV importer any time soon, since you've started working on it, I decided to port over the tests from the desktop client and made some stubs out of the required classes.

Hopefully this will make it easier to integrate your work later on once we merge those changes in.

jagdishrajan commented 5 years ago

Please add an option to import a csv file without having to install the desktop app. Ideally the phone app should be able to import a local csv file. Alternatively we should be able to upload a csv to the site and have it show up on the phone app.

mikehardy commented 5 years ago

I would love to have this feature but have not had the time to implement. The code for the importer is pretty generic and I think there is some support for it already, it just is not finished. PRs welcome!

vi commented 5 years ago

I just keep on using my mini-program that reads semicolon-separated lines and imports them to decks based on filenames.

mikehardy commented 5 years ago

Very interesting! I had missed that earlier comment - thanks for sharing this @vi

github-actions[bot] commented 4 years ago

Hello 👋, this issue has been opened for more than 2 months with no activity on it. If the issue is still here, please keep in mind that we need community support and help to fix it! Just comment something like still searching for solutions and if you found one, please open a pull request! You have 7 days until this gets closed automatically

mikehardy commented 4 years ago

Importing CSV in particular is super popular. Not easy perhaps, but super popular. There was some code (if you browse the repository on the release-2.10 branch it will still be there) commented out in the importer that seemed like it might have been close to working even.

david-allison commented 4 years ago

@mikehardy Could you point me to where this was. Unit tests were commented out between 2.8 and 2.9, but I don't see anything for the importers

https://github.com/ankidroid/Anki-Android/blob/60d6e07ee61305ab5fbd26036bb8f78fd843faa2/AnkiDroid/src/androidTest/java/com.ichi2.anki.tests/libanki/ImportTest.java#L224-L230

mikehardy commented 4 years ago

The importer thing was actually an instrumented test, it's been commented since first commit and was prior to the era when I spliced robolectric into the project so all tests were instrumented

https://github.com/ankidroid/Anki-Android/blob/4b6d202ebeff322e4eaae0bc365dd88317dfe572/AnkiDroid/src/androidTest/java/com/ichi2/anki/tests/libanki/ImportTest.java#L232

david-allison commented 4 years ago

Darn... I was hoping for a silver bullet. The test code is still there, and compiles when commented out.

I've had a shot at the conversion (libAnki is ported with a few TODOs, but the python modules for CSV reading and dealing with files with BOMs are a little more tricky).

My main roadblock: It uses csv.sniffer to detect the type of CSV. The quote detection of this library uses the regex groupindex which Java regexes seem to be missing (I do need to do some more googling).

https://github.com/python/cpython/blob/a74eea238f5baba15797e2e8b570d153bc8690a7/Lib/csv.py#L217-L250

dae commented 1 year ago

CSV is already implemented now, and the others are niche. Closing.