eleybourn / Book-Catalogue

A book cataloging tool for Android phones.
https://github.com/eleybourn/Book-Catalogue/wiki
GNU General Public License v3.0
385 stars 186 forks source link

.csv import problem #594

Closed AnalogDesigner closed 10 years ago

AnalogDesigner commented 10 years ago

To the best of my understanding, I have followed instructions, but importing a .csv file still results in the following error.log below. I am not allowed to attach the .csv file, but first three lines also follows. This may well be something obvious, but as far as I can see this should work. I have also tried the obvious variants, i.e. no ending comma etc. Please do not spend any amount of work on this, but if someone immediately see what's wrong I'd be grateful for a tip.

Best regards, Lars

"_id","author_details","title","isbn","publisher","date_published","rating","bookshelf_id","bookshelf","read","series_details","pages","notes","list_price","anthology","location","read_start","read_end","format","signed","loaned_to","anthology_titles","description","genre","language","date_added","goodreads_book_id","last_goodreads_sync_date","last_update_date","book_uuid", "1","Clarke, Arthur C","Möte med Rama","91-7160-103-1","Trevi","1973","5","1","Default,","1","","248,00","","","0","Lars","","","Inbunden","0","","","","Science Fiction","Svenska","","0", "2","Lundwall, Sam J","Jules Verne Magasinet 419","","Fakta & Fantasi","","4","1","Default,","1","","96,00","","","0","","","","Tidskrift","0","","","","Science Fiction (antologi)","","","0",

An Exception Occured @ 2014-10-23 20:57:48 In Phone HTC Desire HD A9191 (10)

java.lang.RuntimeException: java.lang.ArrayIndexOutOfBoundsException at com.eleybourn.bookcatalogue.backup.CsvImporter.importBooks(CsvImporter.java:344) at com.eleybourn.bookcatalogue.backup.CsvImporter.importBooks(CsvImporter.java:66) at com.eleybourn.bookcatalogue.ImportThread.onRun(ImportThread.java:132) at com.eleybourn.bookcatalogue.ManagedTask.run(ManagedTask.java:117) Caused by: java.lang.ArrayIndexOutOfBoundsException at com.eleybourn.bookcatalogue.backup.CsvImporter.importBooks(CsvImporter.java:140) ... 3 more

Grunthos commented 10 years ago

Looks like you have three coloumns that don't have data.

Either remove them, or add extra commas at end.

AnalogDesigner commented 10 years ago

No, the number of columns is correct. I have exported/imported a dummy register of two books, and that works fine. I am then formatting my own CSV accordingly. Found one issue, the description online is unclear about format, there should not be one book "per line", there should not be any newlines at all. If I merge all lines in my CSV output (using GNU sed) the import is reported as completed, and there are no error messages in the logfile from the import. Only there's still nothing in the database...a pity, the app looks really nice. But I'm not re-entering 2000+ books manually.

Grunthos commented 10 years ago

You are incorrect in two points:

  1. The text you pasted DOES have more header columns than data columns. Just count them.
  2. The description of the import is correct: there should be one book per line.

What I suggest you do is email us (email address in app) the ACTUAL CSV file you are using. Also, after attempting an import of the file you send us, so to 'Help'->'Send Infrmation'.

AnalogDesigner commented 10 years ago

Thank You for replying. I have a few comments + there has been development:

  1. I do not agree. The number of header columns matches the number of data columns. However, I use 30 columns, while your online documentation states 29: https://github.com/eleybourn/Book-Catalogue/wiki/Export-Import-Format But the 30 columns is a direct export from the App (5.0.9), making a small register by scanning ISBN. So I would say your online documentation is not quite up to date here. What is missing is the "language" column, directly after "genre".
  2. Again, the App export outputs everything without newlines. But this point seem moot, also CSV with line ending in newline seem to work (as can be seen below).

My mistake here was the book "_id" field, I did not leave it blank. Doing so, the import starts and runs until it fails after 83 books. Looking at my input the reason for this fail is clear (my export formatting when multiple authors), I have to think about how to make my MSAccess report handle this. But this is my problem, not yours.

Thanks for responding and make me persist.

Best regards, Lars