Differences between revisions 5 and 6
Revision 5 as of 2006-11-23 08:16:59
Size: 2242
Editor: ŁukaszNowak
Comment: ...and more precise...
Revision 6 as of 2008-01-03 13:48:01
Size: 2246
Editor: localhost
Comment: converted to 1.6 markup
Deletions are marked like this. Additions are marked like this.
Line 2: Line 2:
First [:Download:install] ERP5 and [:HowToInstallBusinessTemplates:some modules], then install ''erp5_csv_style'' Business Template. Now create ''Script (Python)'' object with id '''Base_importCsvLine''' in ''portal_skins/custom'' folder with content: First [[Download|install]] ERP5 and [[HowToInstallBusinessTemplates|some modules]], then install ''erp5_csv_style'' Business Template. Now create ''Script (Python)'' object with id '''Base_importCsvLine''' in ''portal_skins/custom'' folder with content:
Line 33: Line 33:
   * [:ŁukaszNowak:I] suggest to replace newline with some special combination of charaters, to made it post-import praseable.    * [[ŁukaszNowak|I]] suggest to replace newline with some special combination of charaters, to made it post-import praseable.
Line 37: Line 37:
[:ŁukaszNowak:IMHO] the best way to analyze problems is to turn off activities. To do so replace: [[ŁukaszNowak|IMHO]] the best way to analyze problems is to turn off activities. To do so replace:

System preparation

First install ERP5 and some modules, then install erp5_csv_style Business Template. Now create Script (Python) object with id Base_importCsvLine in portal_skins/custom folder with content:

   1 if object_property_dict.has_key('uid'):
   2   object = context.portal_catalog.getObject(object_property_dict['uid'])
   3 else:
   4   object = context.newContent()
   5 
   6 # activity doesn't support security rights yet...
   7 for key in ['uid','id']:
   8   if object_property_dict.has_key(key):
   9     object_property_dict.pop(key)
  10 
  11 object.edit(**object_property_dict)

(For now original version of Base_importCsvLine has little problem).

CSV file preparation

Create CSV file, which is like in this example:

"title" "corporate_name" "vat_code" "default_address_region" "default_address_city" "role"
"title" "corporate_name" "vat_code" "default_address_region" "default_address_city" "role"
"Ventis" "Ventis s.c." "1234567889" "1/1" "Tarnowskie Góry" "producer"

Where:

  • first two lines containing name of fields, which you would like to import, eg in case of Organisation (TODO: second will be ignored, isn't it?):
  • third and next lines are with data, like:

Every line shall be separated with enter. To have special characters in your data:

  • replace " with ""
  • replace newline-character with TODO
    • I suggest to replace newline with some special combination of charaters, to made it post-import praseable.

Problems with importing

IMHO the best way to analyze problems is to turn off activities. To do so replace:

   1 method(priority=4, activity="SQLQueue", passive_commit=1).Base_importCsvLine(attribute_value_dict)

with

   1 context.Base_importCsvLine(attribute_value_dict)

in Base_importCsvFile. (Of course copy it from erp_core skin folder to custom before customization.)

Note: importing take some time. Long time sometimes - in our case it took longer than writing this wiki-page and drinking much of wine (working on Duron 600 with 768MB of RAM).

Special thanks to Tomasz Brzezina for support and testing data.

HowToImportDataFromCSV (last edited 2008-01-03 13:48:01 by localhost)