Python – re (Regular Expression) 模組
測試環境為 CentSO 8 (虛擬機) 在 Python 可以透過 re 模組來使用 Regular Expression (正規表達式) 來處理資料, 下面來看一下常用的 re 函數 . re.match(pattern, string, flags=0) 要特別注意這個函數的匹配須從字串的起頭 […]
測試環境為 CentSO 8 (虛擬機) 在 Python 可以透過 re 模組來使用 Regular Expression (正規表達式) 來處理資料, 下面來看一下常用的 re 函數 . re.match(pattern, string, flags=0) 要特別注意這個函數的匹配須從字串的起頭 […]
測試環境為 CentSO 8 (虛擬機) 在 Python 可以透過 re 模組來使用 Regular Expression (正規表達式) 來處理資料, 常用的 re 函數請參考 – https://benjr.tw/105370 , 這邊來看一下常用 Regular Expressi […]
測試環境為 CentSO 8 (虛擬機) SQLite 無法像是 MySQL 或是 MariaDB 使用者自訂函數 ( User-Defined Functions ) ,不過我們可以透過 SQLite 的 extensions – https://github.com/nalgeon/ […]
SQLite 沒有 IF 函數,可以使用 IIF 函數來取代,用法是一樣的. IIF 但需要高於 SQLite v3.32.0 以上版本才有提供. 函數說明 The iif(X,Y,Z) function returns the value Y if X is true, and Z otherwi […]
測試環境為 CentOS 8 X86_64 (虛擬機) 如何計算出連續資料的數目,參考文章 – https://stackoverflow.com/questions/36927685/count-number-of-consecutive-occurrence-of-values-in […]
使用 WITH Clause 的方式,參考文章 https://www.sqlite.org/lang_with.html 透過 CTE : Common Table Expressions ,它可以把 SELECT 後整個 Table 儲存起來,共後續 SQL 語法來使用.而 Recursive […]
在 MSSQL (MariaDB) 可以透過以下方式來設定一個暫時使用的變數. 但在 SQLite 卻無這個功能,需透過以下的方式來處里. 執行結果
SQLite 沒有 Concat 函數,可以使用 || 來把兩個字串結合在一起, 參考範例 – https://www.sqlitetutorial.net/sqlite-string-functions/sqlite-concat/ . 執行結果 上面範例兩個字串都連接再一起,中間多加 […]
測試環境為 CentOS8 (虛擬機) 這邊看一下 Python 內建的 CSV 模組,參考範例 – https://shengyu7697.github.io/python-write-csv-file/ Writer 先來看一下 Writer 的方法. csvwriter.write […]
測試環境為 CentOS8 (虛擬機) 怎麼透過 Python 把 SQLiet 的資料匯出成 CSV 格式(CommSeparated Values 以逗號做區隔)的檔案. 我這邊有一個 SQLite 的檔案,裡面有一個資料表 cpu_meminfo 用來記錄目前 CPU 與 MEM 的使用率 ( […]