Tag Archives: table

Solve the ‘UTF-8’ codec can’t decode byte 0xe9 in position 3114: invalid continuation byte error

Today, when using Python to open a file, the following error was reported:

the code is as follows:

movies = pd.read_table('../../dataset/ml-1m/movies.dat', sep='::', header=None, engine='python', encoding='utf-8').to_numpy()

Solution:
change the code to: iso-8859-1 just

movies = pd.read_table('../../dataset/ml-1m/movies.dat', sep='::', header=None, engine='python', encoding='ISO-8859-1').to_numpy()

How to make the import complete smoothly!

When you import an EXP, you may encounter constraints that prevent you from importing.
You can disable constraints to make the import complete!
When importing, I encountered the following problems:
Column 30 MOS
IMP-00019: row rejected due to ORACLE error 2291
IMP-00003: ORACLE error 2291 encountered
ORA-02291: integrity constraint (CMDB.CI_ELEMENT_LOCATION) violated – parent key not found
The processing steps are as follows:
SQL> create table cmdb.configuration_item_bak as select * from cmdb.configuration_item;
Table created.
SQL> alter table cmdb.configuration_item disable primary key;
alter table cmdb.configuration_item disable primary key
*
ERROR at line 1:
ORA-02297: cannot disable constraint (CMDB.PK_CONFIGURATION_ITEM) –
dependencies exist

SQL> Alter TABLE cmDB. configuration_item disable constraint PK_CONFIGURATION_ITEM;
alter table cmdb.configuration_item disable PK_CONFIGURATION_ITEM
*
ERROR at line 1:
ora-02297: cannot disable constraint (CMDB.PK_CONFIGURATION_ITEM) –
dependencies exist

SQL> Alter TABLE CMDB. Configuration_item disable constraint PK_CONFIGURATION_ITEM cascade;
Table altered.
SQL> alter table cmdb.configuration_item disable primary key;
Table altered.
SQL> Alter TABLE cmDB. configuration_item disable constraint PK_CONFIGURATION_ITEM;
Table altered.
 
I thought the import should be ok 🙂
imp/file=cmdb.dmp fromuser=cmdb touser=cmdb ignore=y
But the question remains?
Why is that?The original constraint error here was a violation of the constraint to import data in the file, regardless of whether the constraint on the table was disabled or not.
Just because the table already has the same data as the file, a constraint in the file was violated when importing it.
So you can complete the import by clearing the table data.
truncate table cmdb.configuration_item ;

then import:
-bask-3.00 $imp/file= CMdb.dmp Fromuser = CMDB Touser = CMDB ignore=y
Import: Release 11.2.0.2.0 – Production on Wed Aug 17 03:27:17 2011
Copyright (C) 1982, 2009, Oracle and/or its Affiliates. All rights Reserved.

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.2.0-64bit Production
With the Partitioning option
Export file created by Export :V11.02.00 via conventional path
import done in UTF8 character set and AL16UTF16 NCHAR character set
import server USES AL32UTF8 character set (possible charset)
export client USES US7ASCII character set (possible charset conversion)
. It is important to import CMDB’s objects into CMDB
imported
 

Uncaught TypeError: Failed to execute ‘appendChild’ on ‘Node’: parameter 1 is not of type ‘Node How to Fix

I want to dynamically insert a line of data into tBody, and I write the following code:

html:
        <table id="theList">
        <thead>
            <th>姓名</th>
            <th>年龄</th>
            <th>性别</th>
            <th>操作</th>
        </thead>
        <tbody id="myBody"></tbody>
    </table>


js:

let list = []
let temp = []

list.push({
    name: '张三',
    age: 20,
    sex: '男'
})
list.push({
    name: '赵四',
    age: 19,
    sex: '女'
})
function render(data) {
    var html=[]
    for (let i = 0; i < data.length; i++) {
        let template = '<tr><td>'+data[i].name+'</td><td>'+data[i].age+'</td><td>'+data[i].sex+'</td><td><a href="javascript:;">修改</a>&nbsp;&nbsp;<a href="javascript:;">删除</a></td></tr>'
        html.push(template)
                                    document.getElementById('myBody').appendChild(html.join(''))
    } 
}
render(list)

The browser throws an Uncaught TypeError when running the above code: Failed to execute ‘appendChild’ on ‘Node’ : parameter 1 is not of type ‘Node’. To find out the cause of the error by looking up data:
AppendChild () requires that a tr object be passed in, not a tr string
and html.join(“) above is a string

console.log(typeof html.join(''))  //stirng

Solution:
render function

function render(data) {
    for (let i = 0; i < data.length; i++) {
        let tr = document.createElement('tr')
        tr.innerHTML = '<td>'+data[i].name+'</td><td>'+data[i].age+'</td><td>'+data[i].sex+'</td><td><a href="javascript:;">修改</a>&nbsp;&nbsp;<a href="javascript:;">删除</a></td>'
        document.getElementById('myBody').appendChild(tr)
    } 
}

Tr is an object. Instead of writing like this, you might as well just write:

function render(data) {
    var html=[]
    for (let i = 0; i < data.length; i++) {
        let template = '<tr><td>'+data[i].name+'</td><td>'+data[i].age+'</td><td>'+data[i].sex+'</td><td><a href="javascript:;">修改</a>&nbsp;&nbsp;<a href="javascript:;">删除</a></td></tr>'
        html.push(template)
        document.getElementById('myBody').innerHTML = html.join('')
    } 
}

Operation effect:

Other features are still being implemented… .

MySQL creates tables and sets auto increment of primary keys

mysql创建表:

mysql>创建表用户(
->userid int(4)主键not null auto_increment,
->用户名varchar(16)不为空,
->userpassword varchar(32) not null
-&gt

创建表log(
logid int(4) primary key not null auto_increment,
logtitle varchar(32) not null,
logcontent varchar(160) not null,
logtime datetime not null,
userip varchar(64) not null
)


Lua — using remove to delete table data

in Lua, everything is table, all the data, functions are stored in table, but when we use table, how to clean up the table table data.
first see a function:
table.remove(table[,pos]) : delete the element on pos position, the latter element will move forward one, and then the deleted index will move forward, resulting in the deleted data is not what you want. When pos is not filled in, the data at the end of the table is deleted.
see the following code:

local array = {"a","a","a","b","a","a","b"}
for i,v in ipairs(array) do
    if v == "a" then
        table.remove(array, i)
    end
end
for i,v in ipairs(array) do
    print(i,v)
end

output result:

we wanted to delete all “a” data in the table, but the output result did not delete all “a” data. So we want to continuously delete the table data can not be used in this way, here is the correct way to delete.

local array = {"a","a","a","b","a","a","b"}
for i=#array,1,-1 do
    if array[i] == "a" then
        table.remove(array, i)
    end
end
for i,v in ipairs(array) do
    print(i,v)
end

so you get the correct deletion.
so we can encapsulate a function


-- 删除table表中符合conditionFunc的数据
-- @param tb 要删除数据的table
-- @param conditionFunc 符合要删除的数据的条件函数
local function table.removeTableData(tb, conditionFunc)
    -- body
    if tb ~= nil and next(tb) ~= nil then
        -- todo
        for i = #tb, 1, -1 do
            if conditionFunc(tb[i]) then
                -- todo
                table.remove(tb, i)
            end
        end
    end
end

-- 删除数据是否符合条件
-- @param data 要删除的数据
-- @return 返回是否符合删除data条件
local function removeCondition(data)
    -- body
    -- TODO data 符合删除的条件
    return true
end

we just need to write TODO and pass in the table.