Help

2

How to import multiple lines text fields with CSV ?

Avatar
WANTELLET Sylvain

When I use export tool, carriage returns in fields (eg: partner comment, product description) are converted into spaces.

When I re-import the generated file, there is no more CR in fields, the whole content is in one line separated with spaces.

Is it possible to import data fields with multiples lines with CSV file ?

Avatar
Discard
3 Answers
1
Avatar
Mohammad Alhashash
Best Answer

You should add double quotes " around fields with special characters including new line.

OpenERP uses the standard python csv module to decode csv input with the parameters: quotechar='"', delimiter=','.

2 Comments
Avatar
Discard
Avatar
Ray
-

This solution works fine for import, but when you export datas from openERP, make some modifications and want to re-import them, you must put CR again on each description lines that already have before export.

Avatar
WANTELLET Sylvain
-

I agree, import works fine with CR within delimiters and export of such imported data is OK too. But records created or modified with OpenERP interface are not exported correctly (CR are converted into space). It's a little annoying...

2
Avatar
Ray Carnes
Best Answer

It normally works fine - I have never had this problem

The file at http://www.filedropper.com/respartner was directly exported from OpenERP 7.0 and all carriage returns are preserved.

It sounds like it is either the editor you are using; the method you are using to get the file to your computer (email, file transfer); or something to do with your regional settings that affect field delimeters.

4 Comments
Avatar
Discard
Avatar
WANTELLET Sylvain
-

There is no carriage returns into fields in your example file. Carriage returns are only at the end of the lines to separate records.

Avatar
WANTELLET Sylvain
-

I'm sorry but I still can't see carriage returns (with various editors) in your file except at the end of the lines. Can you tell me on which record and in which field ?

Avatar
WANTELLET Sylvain
-

Never mind Ray. I just wondered if I wasn't becoming crazy. But my problem is still here. I think it's not possible to import fieds that contains multiples lines of text.

Avatar
Ray Carnes
-

I remember I did need to do this once and had the same problem. I replaced all the carriage returns with a proxy character like ~ hoping that I could then fix the problem after they were imported. This was so long ago I think I gave up because it was too hard for me.

1
Avatar
Ahmet Altinisik
Best Answer

Yes it is possible, I do it everyday without any problem. (with V6.1) OpenERP csv import and export feature works without any problem.

You should use a better csv file editor. I use ASAP extension for excel to import and export csv files http://www.asap-utilities.com

Openoffice also imports csv files nicely however cannot export them nicely (if you have HTML tags and CR LF characters in the fields.

For changing encoding of files to UTF-8 I use Notepad++ (cut the text -> change the encoding -> paste the text back)

2 Comments
Avatar
Discard
Avatar
WANTELLET Sylvain
-

I'm OK with you, import/export works very well. But with fields like comments, notes which can contains multiples lines (separated with CR/LF), import/export doesn't work. It is impossible to handle multiple lines. CR are converted into spaces in export, and it's impossible to import CR/LF into one field.

Avatar
Ahmet Altinisik
-

I did not see any CR in the fields either. I am using Notepad++.