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 久久免费视频网站,日本一道本在线视频,亚洲不卡电影

          整合營銷服務商

          電腦端+手機端+微信端=數據同步管理

          免費咨詢熱線:

          CSV to SQLConverter方便的數據格式

          CSV to SQLConverter方便的數據格式轉換工具

          SV to SQL Converter是一款文件格式轉換工具,用戶能夠使用這款軟件方便的將CSV格式的文件轉換為SQL文件進行保存。軟件使用方式簡單,具有簡單的使用界面,并且支持輸出為UTF-8或者ANSI兩種不同的編碼格式,并且能夠自定義文件的保存名稱。

          轉載自當游網,原文地址:http://www.3h3.com/soft/218449.html

          、前言

          在日常運維的過程中,執行腳本,生成excel報表并發送郵件到郵箱是不可避免的,python生成excel的庫有很多,這里選擇生成csv格式,因為python內置,不需要額外安裝模塊,而且使用簡單。

          二、生產CSV代碼

          # 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)

          生成的文件:

          二、發送郵件代碼

          oi框架 framework-poi

          > 簡單、好用且輕量級的海量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>
          

          關注后私信“FrameworkPoi”就會收到詳細文檔介紹,喜歡的關注下每天會推出更多技術精品。


          主站蜘蛛池模板: 国产免费一区二区三区在线观看| 蜜桃视频一区二区| 国产亚洲自拍一区| 精品成人一区二区三区免费视频| 免费萌白酱国产一区二区三区| 国产激情一区二区三区在线观看| 精品无码AV一区二区三区不卡| 国产高清一区二区三区四区| 无码精品前田一区二区| 国产一区二区在线观看| 在线观看一区二区三区av| 亚洲福利视频一区| 水蜜桃av无码一区二区| 久久精品一区二区三区日韩| 中文字幕一区二区视频| 久久无码人妻精品一区二区三区| 国产成人精品a视频一区| 一区二区视频在线免费观看| 无码人妻精品一区二区蜜桃AV| 国产精品美女一区二区 | 亚洲熟妇成人精品一区| 国产成人精品第一区二区| 久久精品国产第一区二区三区 | 一区二区三区观看| 精品女同一区二区| 精品人妻一区二区三区毛片| 国产亚洲欧洲Aⅴ综合一区| 亚洲永久无码3D动漫一区| 性色av一区二区三区夜夜嗨| 99精品一区二区三区| 亚洲av无码成人影院一区| 国产精品资源一区二区 | 国模一区二区三区| 欧洲精品一区二区三区在线观看| 欧洲精品一区二区三区在线观看| 国产在线一区二区在线视频| 国产精品视频一区二区噜噜 | 国产精品99无码一区二区| 日韩人妻无码一区二区三区综合部| 国产无线乱码一区二三区| 国产一区在线mmai|