Bulk Import task with text qualifier - ssis

SSIS Bulk Import data transformation Row/Column delimiter definition. Trying to import from a csv file to sql table. After doing the import data/values come as follows
Col1 col2 col3
"XXX" "BBN" "BBB"
"XXX" "BBN" "BBB"
"XXX" "BBN" "BBB"
data/values are wrapped around double quotes.
How can i fix this.
Connection manager for csv file has text qualifer: " ,
header row delimiter has {CR}{LR}
unforunately bulk import doesn't have text qualifier

Here's a way to setup an XML format file to handle CSV with double quotes:
<?xml version="1.0"?>
<BCPFORMAT xmlns="http://schemas.microsoft.com/sqlserver/2004/bulkload/format" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<RECORD>
<FIELD ID="0" xsi:type="CharFixed" LENGTH="1"/>
<FIELD ID="1" xsi:type="CharTerm" TERMINATOR="","" MAX_LENGTH="12"/>
<FIELD ID="2" xsi:type="CharTerm" TERMINATOR="","" MAX_LENGTH="38"/>
<FIELD ID="3" xsi:type="CharTerm" TERMINATOR="","" MAX_LENGTH="50" COLLATION="SQL_Latin1_General_CP1_CI_AS"/>
<FIELD ID="4" xsi:type="CharTerm" TERMINATOR="","" MAX_LENGTH="11" COLLATION="SQL_Latin1_General_CP1_CI_AS"/>
</RECORD>
<ROW>
<COLUMN SOURCE="1" NAME="SequenceID" xsi:type="SQLINT"/>
<COLUMN SOURCE="2" NAME="TransactionID" xsi:type="SQLUNIQUEID"/>
<COLUMN SOURCE="3" NAME="Product_Name" xsi:type="SQLVARYCHAR"/>
<COLUMN SOURCE="4" NAME="Product_Code" xsi:type="SQLVARYCHAR"/>
</ROW>
</BCPFORMAT>
If you want to handle pipe-delimited instead, change "","" to ""|""

Related

Hide string name from field in odoo 12

When you define a field in odoo, by default, it displays the string for that value and next to it, the value.
If you don't put the field between group tags, the string value, doesn't appear.
The problem is that I am defining a tree view which doesn't contain group tags:
<record model="ir.ui.view" id="field_partida_fertilizer_tree">
<field name="name">field.diary.partida.fertilizer.tree.view</field>
<field name="model">field.diary.partida.fertilizer</field>
<field name="priority" eval="17"/>
<field name="arch" type="xml">
<tree string="Fertilizante">
<field string= 'Nombre' name="fertilizer"/>
<field string='N' name="nitrato" options='{"show_string": False}' widget="percentpie"/>
<field string='P' name="fosforo" options='{"fg_color": "white"}' widget="percentpie"/>
<field string='K' name="potasio" options='{"fg_color": "white"}' widget="percentpie"/>
<field string='Cantidad (kg)' name="quantity"/>
</tree>
</field>
</record>
By using widget percentpie, I can display this:
I want to hide the letter N next to the graph but not the column and I can't find any property of the widget to do that. The only way I could trick this is by giving the color white to the text so it disappears with the background, but the column cant be centered.
I have tried with the option show_string I found on GitHub but it doesn't work.
Any help would be awesome...
Thank you!
Odoo defines a condition in the PercentPie template to show the string attribute vaue:
<span t-if="widget.string"><t t-esc="widget.string"/></span>
You can alter the template and define a new condition base on a value (show_string ) passed through the options attribute:
<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
<t t-extend="FieldPercentPie">
<t t-jquery="span" t-operation="attributes">
<attribute name="t-if">widget.string and (widget.attrs.options.show_string === undefined or widget.attrs.options.show_string)</attribute>
</t>
</t>
</templates>
Create a new XML file with the above content and add it under the qweb section of the manifest file.
Example:
<record model="ir.ui.view" id="field_partida_fertilizer_tree">
<field name="name">field.diary.partida.fertilizer.tree.view</field>
<field name="model">field.diary.partida.fertilizer</field>
<field name="priority" eval="17"/>
<field name="arch" type="xml">
<tree string="Fertilizante">
<field string='Nombre' name="fertilizer"/>
<field name="nitrato" options='{"show_string": False}' widget="percentpie"/>
<field name="fosforo" options='{"show_string": False}' widget="percentpie"/>
<field name="potasio" options='{"show_string": False}' widget="percentpie"/>
<field string='Cantidad (kg)' name="quantity"/>
</tree>
</field>

XPATH _ Extract values XML

How Can I extract the characteristics values for the following XML code using XPATH?
Example: Extract displayName, firsName, lastName, etc.
This is my XML data:
<directory>
<fieldset>
<field id="displayName">Display name</field>
<field id="firstName">First name</field>
<field id="lastName">Last name</field>
<field id="preferredName">Preferred name</field>
<field id="jobTitle">Job title</field>
<field id="workPhone">Work Phone</field>
<field id="canUploadPhoto">Can Upload Photo</field>
</fieldset>
<employees>
<employee id="229">
<field id="displayName">Susan</field>
<field id="firstName">TestName</field>
<field id="canUploadPhoto">no</field>
</employee>
</employees>
</directory>
You can get actual values along the following XPath expression:
/directory/employees/employee/field[#id="displayName"]/text()

How to index csv files using dih in solr

I am new to solr so I might have wrongly written the dih.I have data already in my solr db and I need to extend my dih file such that it can index csv file which contain more information and csv and solr db data are mapped by common id.What I have done is -find in the code below
This is my csv file-->
Node_IP probe_name Global_ID
10.53.3.87 ILRNAPSUD03 4b44aaff1e09f3d793fe9
10.224.47.26 ILRNAPSUD03 47eebea2c2d485b59
Here is a dih snippet-->
<entity name="tmin"
processor="XPathEntityProcessor"
dataSource="FileDataSource"
stream="true"
url="${pickupdir.fileAbsolutePath}"
onError="skip"
forEach="/execution/"
transformer="script:makePair,script:makeLogPair, TemplateTransformer,
RegexTransformer, HTMLStripTransformer"
>
<field column="jobid_t" xpath="/execution/#jobId" />
<field column="destinationid_t" xpath="/execution/#destinationid" />
<field column="id" template="${tmin.destinationid_t}" />
<field column="log_param" xpath="/execution/log/#severity" />
<field column="log" xpath="/execution/log" />
<entity name="importcsv"
processor="LineEntityProcessor"
url="C:\Users\arpiagar\Desktop\IP Probe name_ILRNAPSUD01.csv"
rootEntity="false"
dataSource="FileDataSource"
header="true"
separator=","
transformer="TemplateTransformer, RegexTransformer,script:mapcsv"
>
<field column="rawLine" groupNames="Node_IP,probe_name,Global_ID"/>
<field column="id" name="Global_ID" />
<field column="probe_name" name="probe_name" />
</entity>
</entity>
I need to map id in the tmin entity with the id which we will get after indexing csv data and index probe_name and node_ip at that particular id.

Odoo - How to create custom global configuration file

I am using Odoo 10-e. I came from .net what i want to do is that i need to create my custom setting configuration file in Odoo like we have AppSettings file in asp.net where we set some static key values to use them in project. How to create that kind of file and how can i access that file in python code or xml files ?
Create a class that inherits from res.config.settings (so you can edit the record):
class farmacia_pedido_config_settings(models.TransientModel):
_inherit = 'res.config.settings'
_name = 'farmacia.config.settings'
lista_precios_defecto = fields.Many2one(
'product.pricelist',
string='Lista de precios por defecto')
Associate with the view:
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_farmacia_configuration" model="ir.ui.view">
<field name="name">farmacia config settings</field>
<field name="model">farmacia.config.settings</field>
<field name="arch" type="xml">
<form string="Farmacia" class="oe_form_configuration">
<header>
<button string="Aplicar" type="object" name="execute" class="oe_highlight"/>
<button string="Cancelar" type="object" name="cancel" class="oe_link"/>
</header>
<field name="lista_precios_defecto" class="oe_inline"/>
</group>
</form>
</field>
</record>
<record id="action_farmacia_configuration" model="ir.actions.act_window">
<field name="name">Farmacia</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">farmacia.config.settings</field>
<field name="view_mode">form</field>
<field name="target">inline</field>
</record>
<menuitem id="menu_farmacia_config" name="Farmacia" parent="base.menu_config"
sequence="3" action="action_farmacia_configuration"/>
</data>
</openerp>
Save in a file accessing via python (this is uglier)
config = ConfigParser()
your_file = os.getenv("HOME")+os.path.sep+"your_file.conf"
if os.path.isfile(your_file):
config.read(your_file)
else:
raise models.except_orm(
'Error',
"File not found " + os.getcwd())

Solr some mdb files are not process as documents in dataimport

I have to import some mdb files to solr. some of mdb files are indexed well as document but there are others don't.
I use Solr 4.10.0 and ucanaccess ver. 2.0.9 The follwoing is a screen shot from the log:
For some missing fields values (in the screen shot case 6 fields) I have set onError="continue" in the dataimport-config:
<document>
<entity name="Book" dataSource="a" query="select bkid AS id, bkid AS BookID,bk AS BookTitle, betaka AS BookInfo, cat as cat from 0bok WHERE bkid = 29435">
<field column="id" name="id"/>
<field column="BookID" name="BookID"/>
<field column="BookTitle" name="BookTitle"/>
<field column="cat" name="cat"/>
<entity name="Category" dataSource="a" query="select name as CatName, catord as CatWeight, Lvl as CatLevel from 0cat where id = ${Book.CAT}">
<field column="CatName" name="CatName"/>
<field column="CatWeight" name="CatWeight"/>
<field column="CatLevel" name="CatLevel"/>
</entity>
<entity name="Pages" dataSource="a1" onError="continue" query="SELECT nass AS PageContent, page AS PageNum FROM book ORDER BY page">
<field column="PageContent" name="PageContent"/>
<field column="PageNum" name="PageNum"/>
<entity name="Titles" dataSource="a1" onError="continue" query="SELECT * FROM title WHERE id = ${Pages.PAGENUM} ORDER BY sub">
<field column="ID" name="TitleID"/>
<field column="TIT" name="PageTitle"/>
<field column="SUB" name="TitleWeight"/>
<field column="LVL" name="TitleLevel"/>
</entity>
</entity>
</entity>
</document>
This is a screen shot for the table regarded in the database with the 6 undefined data fields:
At the end of dataimporting for this mdb file I got the following response:
Last Update: 09:12:04 Requests: 31,952, Fetched: 78,980, Skipped: 0,
Processed: 0 Started: 18 minutes ago
Which it is shown that 0 processed!
There are other mdb files are proceed i.e 1 processed is generated in the response but I have got the folwing errors in the log:
10/7/2014 9:28:08 AM ERROR SolrWriter Exception while solr commit.
this writer hit an OutOfMemoryError; cannot commit...
and
SolrIndexWriter Error closing IndexWriter this writer hit an
OutOfMemoryError; cannot flush...
How could I solve this issue? and why Solr requests and fetched all this records and then process and index none?!