Warning: error_log(/data/www/wwwroot/hmttv.cn/caches/error_log.php): failed to open stream: Permission denied in /data/www/wwwroot/hmttv.cn/phpcms/libs/functions/global.func.php on line 537 Warning: error_log(/data/www/wwwroot/hmttv.cn/caches/error_log.php): failed to open stream: Permission denied in /data/www/wwwroot/hmttv.cn/phpcms/libs/functions/global.func.php on line 537
SV to SQL Converter是一款文件格式轉換工具,用戶能夠使用這款軟件方便的將CSV格式的文件轉換為SQL文件進行保存。軟件使用方式簡單,具有簡單的使用界面,并且支持輸出為UTF-8或者ANSI兩種不同的編碼格式,并且能夠自定義文件的保存名稱。
轉載自當游網,原文地址:http://www.3h3.com/soft/218449.html
在日常運維的過程中,執行腳本,生成excel報表并發送郵件到郵箱是不可避免的,python生成excel的庫有很多,這里選擇生成csv格式,因為python內置,不需要額外安裝模塊,而且使用簡單。
# encoding: utf-8
import codecs
import csv
import datetime
import sys
reload(sys)
sys.setdefaultencoding( "utf-8" )
def to_csv(datas, env):
headers=['ip', u'操作系統', u'分區屬性', u'輸出返回', u'執行結果']
# newline=''避免出現空行
today=datetime.date.today()
filename="{}-{}.csv".format(env, today)
try:
with open(filename, 'wb') as f:
f.write(codecs.BOM_UTF8)
# 標頭在這里傳入,作為第一行數據
writer=csv.DictWriter(f, headers)
writer.writeheader()
writer.writerows(datas)
except Exception as e:
print (u'寫入csv錯誤:' + str(e))
finally:
return filename
if __name__=='__main__':
data=[{"ip": "192.168.1.2", u'操作系統': "LINUX", u'分區屬性': u"x86物理機", u'輸出返回': "ok", u'執行結果': u"成功"},
{"ip": "192.168.1.3", u'操作系統': "LINUX", u'分區屬性': u"x86物理機", u'輸出返回': "error:xxxxxxxxxxx", u'執行結果': u"成功"},
{"ip": "192.168.1.4", u'操作系統': "LINUX", u'分區屬性': u"x86虛擬機", u'輸出返回': "ok", u'執行結果': u"成功"},
{"ip": "192.168.1.5", u'操作系統': "LINUX", u'分區屬性': u"x86虛擬機", u'輸出返回': "ok", u'執行結果': u"成功"}]
env="dev"
to_csv(data, env)
生成的文件:
> 簡單、好用且輕量級的海量excel,csv文件導入導出解決方案。解決火狐瀏覽器中文編碼問題。
> 注:excel的合并功能及復雜功能,使用代碼實現比較復雜,框架只提供單行的導入導出。
引入Maven依賴或下載jar包
<dependency> <groupId>com.github.fartherp</groupId> <artifactId>framework-poi</artifactId> <version>3.0.4</version> </dependency>
CSV常用例子:
CSVRead.read(CSVReadTest.class.getResourceAsStream("/a.csv"), new CSVReadDeal<CsvReadDto>() { // 單條數據處理(每一行對應一個javabean) public CsvReadDto dealBean(String[] arr) { CsvReadDto dto=new CsvReadDto(); dto.setId(Long.valueOf(arr[0])); dto.setName(arr[1]); dto.setAge(Integer.valueOf(arr[2])); return dto; } // 批量數據處理(可以批量入庫) public void dealBatchBean(List<CsvReadDto> list) { Assert.assertEquals("name1";, list.get(0).getName()); Assert.assertEquals("name2", list.get(1).getName()); Assert.assertEquals("name3", list.get(2).getName()); } // 批量加載多少數據,統一處理(默認1000) public int getBatchCount() { return super.getBatchCount(); } // 從第幾行開始加載(默認跳過第一行) public int skipLine() { return super.skipLine(); } });
2.CSV文件導出:
String filename="TEST"; String[] title=SheetsTitlesEnum.USER_LOGIN_LOG.getTitle(); List<String[]> bodyList=new ArrayList<>(); CsvUtil.writeCsvFile(filename, title, bodyList);
3.瀏覽器下載CSV文件:
HttpServletResponse response=null; HttpServletRequest request=null; String filename="TEST"; String[] title=SheetsTitlesEnum.USER_LOGIN_LOG.getTitle(); List<String[]> bodyList=new ArrayList<>(); CsvUtil.writeCsvFile(response, request, filename, title, bodyList);
Excel常用例子:
1.Excel文件導入:
ExcelRead.read(ExcelReadTest.class.getResourceAsStream("/a.xls"), new ExcelReadDeal<ExcelReadDto>() { // 單條數據處理(每一行對應一個javabean) public ExcelReadDto dealBean(Row row) { ExcelReadDto dto=new ExcelReadDto(); dto.setId(new BigDecimal(row.getCell(0).toString()).longValue()); dto.setName(row.getCell(1).toString()); dto.setAge(Integer.valueOf(row.getCell(2).toString())); return dto; } // 批量數據處理(可以批量入庫) public void dealBatchBean(List<ExcelReadDto> list) { Assert.assertEquals("name1", list.get(0).getName()); Assert.assertEquals("name2", list.get(1).getName()); Assert.assertEquals("name3", list.get(2).getName()); } // 批量加載多少數據,統一處理(默認1000) public int getBatchCount() { return super.getBatchCount(); } // 從第幾行開始加載(默認跳過第一行) public int skipLine() { return super.skipLine(); } });
2.Excel文件導出:
String[] title=new String [6]; title[0]="登錄時間"; title[1]="用戶名"; title[2]="訪問端"; title[3]="版本系統"; title[4]="登錄IP"; title[5]="狀態"; String fileName="D:\\style1.xls"; FileExcelWrite.<ExcelDto>build(title, fileName) .setLargeDataMode(false) .deal(obj -> { String[] result=new String[6]; result[0]=obj.getTime(); result[1]=obj.getName(); result[2]=obj.getClient(); result[3]=obj.getVersion(); result[4]=obj.getIp(); result[5]=obj.getStatus() + ""; return result; }) .list(ExcelWriteStyleTest.getList())// 默認情況下導出數據達到excel最大行,自動切換sheet,(xlsx=1048576,xls=65536) .list(ExcelWriteStyleTest.getList1()) .write();
3.Excel文件導出(風格,可以自定義風格):
Map<String, Object> map=new HashMap<>(); map.put("quoteCurrency", "ETH"); map.put("symbol", "USDT_ETH"); map.put("startTime", "2019-01-09 00:00:00"); map.put("endTime", "2019-01-09 12:00:00"); String fileName="D:\\styleInputStream.xls"; FileExcelWrite.<ExcelDto>build(this.getClass().getResourceAsStream("/c.xls"), fileName) .additional(map) .deal(new WriteDeal<ExcelDto>() { public String[] dealBean(ExcelDto obj) { String[] result=new String[3]; result[0]=obj.getId() + ""; result[1]=obj.getName(); result[2]=obj.getAge() + ""; return result; } public int skipLine() { return 4; } }) .list(getList()) .write();
4.瀏覽器下載Excel文件:
String[] title=new String [6]; title[0]="登錄時間"; title[1]="用戶名"; title[2]="訪問端"; title[3]="版本系統"; title[4]="登錄IP"; title[5]="狀態"; String fileName="D:\\style1.xls"; HttpServletResponseExcelWrite.<ExcelDto>build(title, fileName, request, response) .setLargeDataMode(false) .deal(obj -> { String[] result=new String[6]; result[0]=obj.getTime(); result[1]=obj.getName(); result[2]=obj.getClient(); result[3]=obj.getVersion(); result[4]=obj.getIp(); result[5]=obj.getStatus() + ""; return result; }) .list(ExcelWriteStyleTest.getList())// 默認情況下導出數據達到excel最大行,自動切換sheet,(xlsx=1048576,xls=65536) .list(ExcelWriteStyleTest.getList1()) .write();
公告模塊框架 framework-common
包括各種util,例如:日期DateUtil,BigDecimalUtil等等
壓縮框架 framework-compress
提供各種壓縮方式 1.bzip2 2.gzip 3.jar 4.tar 5.zip 6.zlib 7.shell命令(gzip,targz)
核心框架 framework-core
1.整合easyui分頁功能 2.驗證碼 3.整合easyui樹結構 4.統一前端請求后的返回參數 5.發送郵件,包括html郵件
db操作框架 framework-database
封裝操作數據庫的基本操作(增刪改查)
異常體系框架 framework-exception
1.mysql數據庫返回的錯誤信息,轉成可識別信息 2.oracle數據庫返回的錯誤信息,轉成可識別信息 3.通用的異常返回的錯誤信息,轉成可識別信息
文件處理框架 framework-file
1.ftp 2.nfs
net框架 framework-net
1.ftp 2.sftp
poi框架 framework-poi
1.csv讀取及下載 2.excel讀取
加密解密框架 framework-security
1.不可逆:base64,MD5 2.對稱密鑰:AES,DES,3DES 3.非對稱密鑰:RSA
framework-filter
1、支持切面過濾 2、和spring環境集成 配置方式是: web.xml <filter> <filter-name>frameworkFilter</filter-name> <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class> <init-param> <param-name>targetFilterLifecycle</param-name> <param-value>true</param-value> </init-param> </filter> <filter-mapping> <filter-name>frameworkFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> spring 配置文件 <bean id="frameworkFilter" class="cn.vanskey.filter.web.FrameworkFilterFactoryBean"> <property name="filters"> //過濾器配置 <util:map> <entry key="myfilter"> <bean class="com.zrj.pay.cashier.action.demo.MyFilter"/> </entry> </util:map> </property> <property name="filterChainDefinitions"> <value> /**=myfilter //過濾器和路徑的對應關系 </value> </property> </bean>
*請認真填寫需求信息,我們會在24小時內與您取得聯系。