Importing Issues from a CSV file in Youtrack

Don’t get me wrong, I think YouTrack is a great tool. But when it came to importing data from my old bug tracking tool to YouTrack, I was banging my head against the wall. Their current instructions are lacking examples and the whole process seems to have holes. So for anyone looking for CLEAR instructions with examples on how to import data from a CSV file into YouTrack, here it is:

1.) Download the latest version of YouTrack’s Python Client Library and unzip it.

2.) Make sure you have Python installed on your computer

3.) Copy this blank CSV file to <unzipped library directory>\python\csvClient

4.) Add all of your data to the blank CSV file mentioned in step 3.

  • If you need to add new columns, make sure that the name matches exactly what’s in YouTrack. E.g. “Estimation” in the CSV matches with “Estimation” in YouTrack
  • The “Issue Id” column should just be auto incrementing numbers
  • The date fields must match the format specified in the “youtrackMapping.py” file mentioned below.  Feel free to update your file if needed

5.) Overwrite the “youtrackMapping.py” file in the <unzipped library directory>\python\csvClient directory with this one.

6.) Execute the following command from the <unzipped library directory>\python\ directory

python csv2youtrack.py csv_file youtrack_url youtrack_login youtrack_password

Here’s what mine looks like python csv2youtrack.py csvClient/import.csv http://test.myjetbrains.com/youtrack youtrack_login youtrack_password

7.) The script will probably take forever to run, but give it time.  If it error’s out, I’ve listed some common errors and solutions below.

Common Errors

Traceback (most recent call last): File "csv2youtrack.py", line 140, in main() File "csv2youtrack.py", line 20, in main csv2youtrack(source_file, target_url, target_login, target_password) File "csv2youtrack.py", line 31, in csv2youtrack source = Client(source_file) File "/Users/tony/Downloads/youtrack-rest-python-library-master 2/python/csvClient/client.py", line 8, in __init__ self._header = self._read_header() File "/Users/tony/Downloads/youtrack-rest-python-library-master 2/python/csvClient/client.py", line 11, in _read_header header = self._get_reader().next() _csv.Error: new-line character seen in unquoted field - do you need to open the file in universal-newline mode?

This occurs when the newline characters in the csv are ill formatted, usually due to Mac OS.  Resave the CSV using Unix or Windows line endings.

4 thoughts on “Importing Issues from a CSV file in Youtrack

  1. Carolina says:

    Hello,

    I finally could import all the issues into YOUTRACK, but the fields of estimation and time spent don´t get the information like the others, Do you khow what am I doing wrong, thanks. This is my mapping file and my test file. Thank you very much.

    =========================

    import csvClient

    csvClient.FIELD_NAMES = {
    “ID de la incidencia” : “numberInProject”,
    “Proyecto” : “project_name”,
    “Etiquetas” : “tag”,
    “Resumen” : “summary”,
    “Notificador” : “reporterName”,
    “Creada” : “created”,
    “Tipo” : “type”,
    “Tipo_Tarea” : “Tipo_Tarea”,
    “Estado” : “state”,
    “Planificacion” : “Planificacion”,
    “Estimacion” : “Estimation”,
    “Tiempo empleado” : “Spent time”,
    “Cliente” : “Cliente”,
    “Facturacion” : “Facturacion”,
    “Cobro” : “Cobro”,
    “Valor [$]” : “Valor [$]”,
    “% de Avance” : “% de Avance”,
    “Fecha de Inicio” : “Fecha de Inicio”,
    “Fecha de Vencimiento” : “Due Date”
    }

    csvClient.FIELD_TYPES = {
    “Creada” : “UNIX Epoch timestamp “,
    “Tipo” : “enum[1]”,
    “Tipo_Tarea” : “enum[1]”,
    “State” : “state[1]”,
    “Planificacion” : “enum[1]”,
    “Valor [$]” : “string”,
    “% de Avance” : “integer”,
    “Fecha de Inicio” : “date”,
    “Due Date” : “date”
    }

    csvClient.CSV_DELIMITER = “,”
    csvClient.GENERATE_ID_FOR_ISSUES = False
    csvClient.DATE_FORMAT_STRING = “%Y-%m-%d %H:%M:%S”

    ==============================000

    “ID de la incidencia”,”Proyecto”,”Etiquetas”,”Resumen”,”Notificador”,”Creada”,”Tipo”,”Tipo_Tarea”,”Estado”,”Planificacion”,”Estimación”,”Tiempo empleado”,”Cliente”,”Facturacion”,”Cobro”,”Valor [$]”,”% de Avance”,”Fecha de Inicio”,”Fecha de Vencimiento”
    “1”,”TEST2″,”ENT”,”Firmware robustecido “,”Aquiles Cusa”,”2014-09-18 00:00:00″,”Tarea”,”ENT”,”Terminadas”,”Planificada”,”0m”,”0m”,”INVAP”,”A_Facturar”,”No_Cobrada”,”60400″
    “2”,”TEST2″,””,”Ensayos “,”Aquiles Cusa”,”2014-09-18 00:00:00″,”Tarea”,”Otra”,”Terminadas”,”Planificada”,”1s2d4h”,”7h”,”INVAP”,”A_Facturar”,”No_Cobrada”,””
    “3”,”TEST2″,””,”Desarrollo “,”Aquiles Cusa”,”2014-09-18 00:00:00″,”Tarea”,”Otra”,”Terminadas”,”Planificada”,”2s2d4h”,”1s2d”,”INVAP”,”A_Facturar”,”No_Cobrada”,””
    “4”,”TEST2″,””,”Revision de firmware original con respecto a los inconvenientes informados”,”Carolina Calderon”,”2014-09-18 00:00:00″,”Tarea”,”SW_UC”,”Terminadas”,”No_Planificada”,”0m”,”2s”,”INVAP”,”No_Facturada”,”No_Cobrada”,””
    “5”,”TEST2″,””,”Firmware “,”Aquiles Cusa”,”2014-09-18 00:00:00″,”Tarea_Madre”,”Otra”,”Nuevas”,”Planificada”,”4s”,”1s2d7h”,”INVAP”,”__”,”__”,””
    “6”,”TEST2″,””,”Gestion “,”Aquiles Cusa”,”2014-09-18 00:00:00″,”Tarea_Madre”,”Otra”,”Nuevas”,”Planificada”,”2d”,”1d”,”INVAP”,”__”,”__”,””
    “7”,”TEST2″,””,”Seguimiento del proyecto “,”Aquiles Cusa”,”2014-09-18 00:00:00″,”Tarea”,”Otra”,”Nuevas”,”Planificada”,”2d”,”1d”,”INVAP”,”__”,”__”,””

  2. Jeff N. says:

    Your post helped a lot, but I had two issues.

    1) Required a ‘Project’ in the CSV. I created a new column in my spreadsheet called ‘Project’ and named all rows to the project that I was importing.

    2) While importing any date/time, the system couldn’t handle timezones. I removed the ‘ -8:00’ from rows and it workd.

Leave a Reply

Your email address will not be published. Required fields are marked *