How can i import a CSV file?

Help
2009-09-17
2013-04-14
  • nick martin
    nick martin
    2009-09-17

    It  seems pretty difficult to import the supermemo file. I hope it is easier to import the CSV file.

     
  • Christa Runge
    Christa Runge
    2009-09-17

    Hi nickmartin,

    yes, you are right, the Supermemo file is binary, and for this reason you need several perl libraries to decode this binary format.
    The CSV import is also based on perl scripts, but it does not need these libraries.

    ########## Importing databases from a CSV file

    The Perl program 'tools/import_csv.pl' allows importing data from csv files. It can create a new database or add the data to an
    existing one.

    In csv files the data values are separated by colons, the values may be protected by ", double quotes in the data have to be doubled.
    csv files can be easily created with the export function of a spread sheet.

    The import function only imports the category and data fields of a card:
    - The first column is the category name. If the category doesn't exist it is created.
    - The next 6 columns are the card data. empty or missing columns result in empty data fields. If the cell is protected by double quotes it may contain
      newlines.

    'tools/import_csv.pl -h' displays usage information.
    'tools/import_csv.pl -s -d l_csv-test.db csv-test.csv' converts the csv file 'csv-test.csv' to the karatasi database
    file 'l_csv-test.db'.

    ####################################################################################-

    However, the CSV import is content only. So you will get the text of your cards, but you will loose your learning history. All cards which you import as CSV will start the learning cycle from the beginning.
    For this reason we recommend the CSV import for new data only.

    Regards,

    Christa

     
  • nick martin
    nick martin
    2009-09-18

    it's still complicated to me. I want to memorize new English words on my iphone. so I used Database Wizard---Language Trainer--English(New language)--Chinese(known language), so I have a database called "English" now. When i click on "enlgish", there are 3 subfolder(Category?), called "English","Chinese" and "phrases".
    This is my understanding, there are three "file drawer"-English, chinese, and phrases in a cabinet called"English", so i can created different cards that go to English, chinese or phrase.
    I have a CSV file in this format, English word---pronunciation---Chinese explanation. Sample:
    blazing adj.炽烧的, 闪耀的, 强烈的
    U said "**The first column is the category name"**, that means if I want to all these cards in one "card file", I should name the first column as either "English", "chinese" or "phrases". Say name column A as "English", so I will have 4 columns for this CSV file.
    By the way, which file i need to download to work on winxp?
    https://sourceforge.net/projects/karatasi/files/ there are 4 different files.

     
  • Christa Runge
    Christa Runge
    2009-09-19

    Hi nickmartin,

    (1)  which file to download? - there are two small bundles (karatasi-httpd, ~ 16 kB) and two large bundles (karatasi, ~17 MB). The small bundles contain only the cgi scripts to setup a server for karatasi database transmission between your iPhone and the PC. The large bundles contain additionally the Perl scripts for data import to karatasi database format, and the source code. So if you want the import scripts then get one of the large bundles. The content is the same, only the zip format differs. Choose the .gz or the .bz2 format, whichever is supported better in your OS. You find then the import scripts in the tools folder, and the instructions in the README and INSTALL files.

    (2) Every row in the CSV file will create one card, that is a question together with its answer. The first column is the category - indeed a kind of subfolder. The second column is the question, the third is the answer, and then follow additional optional columns which are also shown together with the answer.

    (3) Going back to your example: say column A as 'English', then the next column (english word) will be the question, the other columns (pronounciation, and Chinese explanation) are shown in the answer. This is the default layout style; however you may modify the layout style per category according to your needing. E.g. you might want to show the prononciation together with the english word as question.

    (4) If you want also a reverse question (chinese word as question / english translation as answer) you need to copy the row manually in the CSV and then swap the columns. Alternatively, the iPhone application provides a function to copy a single card, and then a function to swap the card fields (corresponding to swapping the columns in the CVS). For these reverse cards you may want to use a different category.

    (5) Although the database wizard creates the three categories (subfolders) by default, you may extend it to more categories as you like. Just use the additional category names in the first row of your CSV. For example, I am using one category for antonyms (pairs of opposites), e.g. the question is "dark" and the answer is "light".

    Regards,

    Christa

     
  • Christa Runge
    Christa Runge
    2009-09-19

    Hi nickmartin,

    I forgot one thing. It is not necessary to go through the CSV, you can create new cards directly on the iPhone instead. Use the data wizard for this, and you will get a new card together with its reverse card.

    Also you can customize the titles of the card fields, e.g. one titled as 'prononciation'.

    Regards,

    Christa

     
  • nick martin
    nick martin
    2009-09-20

    Thank you very much for this detailed answer, Christa. I will try it at home later. but if u guys can make it easier to import file, that will be better.

     
  • Sidney
    Sidney
    2011-02-21

    I have started using the CSV import function in the karatasi Java app.  It works well with files created by the "Save As…" funcition in MS/Excel with CSV format.  Non-English special characters such as the French acute accent  display properly and display on the iPhone.  The encoding for this character  is as a Hex 'E9' which is not part of the UFT-8 character set.

    However, special characters such as "International Phonetics Alphabet (IPA)" such as "open o ' do not display properly.  They do not display properly even when in UFT-8 format as hex 'c9 94' for the "open o" .  Any suggestions?

     
  • Christa Runge
    Christa Runge
    2011-02-25

    Hi Sidney,

    the UTF-8 encoding is the default for the csv import to karatasi, but it is not the only encoding supported.
    You can select the encoding for reading the csv file in the menu Fiile / Settings.
    This feature is available since karatasi version 0.2.1.
    So try to find out the character encoding how your Excel file was stored.
    If the encoding matches, then also special characters should display fine (as long as the iPhone display driver supports them).

    Christa

     
  • Sidney
    Sidney
    2011-02-26

    Thanks Christa,

    That was the exactly what I needed.  I just had never noticed that the CSV import coding could be specified in karatasi java.  As it turned out, mine was set to "System Default" which may be UFT-8, but I ran it with specifically choosing UFT-8 as my setting. I got the all my characters including the full French character set and all the phonetic (IPA) symbols properly resolved on my iPhone. 

    I never did find out what MS/Excel uses for "save as…" when you specify "csv" format, but whatever it is, it isn't uft-8 and I could never get it to come out as uft-8.   Instead, I opened my Excel file in Open Office Calc where the "save as…" plainly leads you through all the specifications to the proper unicode.  It also puts quotes around the text in each cell so that internal commas don't ruin the cell layout when you export. 

    Anyway,  MS/Excel (.xlsx)  to OO Calc  to (.cvs) to karatasi java import works perfectly.

    Thanks again,
    Sidney