大éã®ãã¹ããã¼ã¿ãå¿«é©ã«ä½ãï¼ã¤ã®ã³ã - è² è·ãã¹ãã®ããã«Excelï¼VBAããã¾ã使ã
Webã¢ããªã±ã¼ã·ã§ã³ãå®éç¨ã«èããããã©ãããã¹ãããããã«ã¯ï¼
大éã®ãã¹ããã¼ã¿ãå¿ è¦ã«ãªãã
è¦æ¨¡ã«ããããï¼å ´åã«ãã£ã¦ã¯ï¼ãã¼ãã«ãããï¼æ°åä¸ãæ°ç¾ä¸ã¬ã³ã¼ããè¦æ±ãããã ããã
ã·ã¹ãã ã®è² è·ãã¹ããå®æ½ããéã«ã¯ï¼
ï¼ï¼ï¼ï¼
ãã·ã¹ãã ã®å é¨ã«ä¿æããè² è·ãã¤ã¾ããDBã®éãããã¾ãä½ãåºãï¼
SQLå®è¡æ§è½ãç¾å®ã®éç¨ç¶æ ã«åããã¦ãã¥ã¼ãã³ã°ããã
ï¼ï¼ï¼ï¼
ãã®å¾ã§ï¼ãã·ã¹ãã ã®å¤é¨ã§çºçããè² è·ãã¤ã¾ãåæã¢ã¯ã»ã¹ãããããããããµã¼ãã¼ã®éãã¨ãªãã
ããã¦åæ©è½ãã¼ã¸ã®ããã©ã¼ãã³ã¹ã測å®ããã
å¾è ã¯ï¼jmeterãªã©ã®ä¾¿å©ãªãã¼ã«ãåå¨ããã
ãï¼åè ã®ããã¼ã¿çæãã«é¢ãã¦ã¯ï¼æ¹æ³ãããã»ã©ç¢ºç«ãã¦ããªãããã«æããã
ä¸è¨ã¯ï¼ãããã£ã大éã®ãã¼ã¿ããã¾ãä½ãããã®ã¡ã¢ã
- (ï¼)ãExcelã§ãã¼ã¿ãä½ãã¹ã
- (ï¼)ãã§ããã° Excel㯠2007 以éã使ãã¹ã
- (ï¼)ãä½æ¥åã«ï¼èªåä¿åããªãã«ãã¹ã
- (ï¼)ãï¼ã¤ã®ã¨ã¯ã»ã«ãã¡ã¤ã«ã«ï¼ã¤ã®ãã¼ãã«ã ããå ¥ããã¹ã
- (ï¼)ããã¼ã¿ã®å¨ææ§ã»é段æ§ãç解ãã¹ã
- (ï¼)ããã¯ãã§ãã£ã«ãã¹ã
- (ï¼)ãcsvã«ã¨ã¯ã¹ãã¼ããã¹ã
- ã¾ã¨ã
(ï¼)ãExcelã§ãã¼ã¿ãä½ãã¹ã
ã¨ã¯ã»ã«ã®ã¤ã³ã¿ãã§ã¼ã¹ã¯ï¼é£ç¶ãã¼ã¿ããç´æçãã«çæããã®ã«æé©ã ããã
ãããªãinsert ... ã¨ææ¸ãã§DMLæãä½ãå§ããå¿ è¦ã¯ãªããã¾ãæåã®æ°ä»¶ãæ°å件ã®ãã¼ã¿ã ãï¼Excelã®ã·ã¼ãä¸ã§ä½æããäºã«ãããã
- åãã«ã©ã ï¼1è¡ã1ã¬ã³ã¼ãã¨ã¿ãªãã
- æåã®è¡ã«ã¯ãã¼ãã«å®ç¾©ãã³ãããã¦ããã
- ãã¼ãã«å®ç¾©ã®ä¸ã«ï¼ã¬ã³ã¼ãã®å 容ãæ¸ãã¦ããã
- æåã®1件ã2件ãæå ¥åãããï¼ãã¨ã¯ãã£ã«ã§é£ç¶ãã¼ã¿ãçæãããæå³ã¨éããã®ãã§ãããä¿®æ£ããã
ããã¯ï¼é常ã«ç´æçãªæ¹æ³ã ã
- Perlãªã©ã®ã¹ã¯ãªããè¨èªã§ãã¼ã¿ãçæãã¦ããæ¹æ³ã¨ç°ãªãï¼ãè¨ç®å¼ãã©ã®ãããªå¤ã»çµæã«ãªãããããã®å ´ã§ãããã
- 該å½ããè¡ã¨ã«ã©ã ãè¦ã¤ããã®ã¯æ¥µãã¦ç°¡åã ããä»ï¼ããï¼ã¤ã®ã«ã©ã å ã§ï¼é£ç¶ãã¦ã©ã®ãããªãã¼ã¿ãçæãããã®ãï¼ãã¨ããäºãä¸èªãã¦ææ¡ã§ããã
- ããã¼ãã«å ã®å ¨ã¬ã³ã¼ããï¼ã«ã©ã ã ãä¿®æ£ããããã¨ããå ´åãï¼ãã®åã ããã£ã«ããã°æ¸ãã
- ã»ã«å ã§ã®ç¹æ®æåã®ã¨ã¹ã±ã¼ããï¼DMLæãææ¸ãã§æ¸ãå ´åã»ã©ã«æ°ã«ããå¿ è¦ããªãã( æé ã® ' ã ãã¯2åéãã¦æ¸ãå¿ è¦ããããã¾ãï¼ãã¼ã¿ã®ç¨®é¡ã¯ãæ¨æºããããæååããæ°å¤ããªã©ã«é©å®å¤æ´ãã¦ããã¨ãã)
ãªãã©ã³ãã ãã¼ã¿ã®çæãã¼ã«ã¨ãããã®ãå¤æ°åå¨ãããï¼ãã¼ãã«éã«å¤æ°ã®ã¢ã½ã·ã¨ã¼ã·ã§ã³ãããå ´åï¼å¯¾å¿ããããªãã
(ï¼)ãã§ããã° Excel㯠2007 以éã使ãã¹ã
97 - 2003ã¾ã§ã®Excelã§ã¯ç´6ä¸5000件ãéçã ã£ããï¼Office 2007ã§ã¯ç´104ä¸è¡ã¾ã§ã®è¡æ°ãæ±ããããã«ãªã£ãã
ç¾ä¸ä»¶ãè¶ ãã件æ°ã®ãã¼ã¿ãå¿ è¦ãªå ´åã«ã¯ï¼å¾è¿°ãããã¯ãã§ã®ãã£ã«å¦çãï¼è¤æ°ã·ã¼ãã«ããã£ã¦å®æ½ãããã調æ´ããã°ããã
ã¾ãExcel2007ã«ããã°ï¼97 - 2003 ã¾ã§ã®å½¢å¼ã«æ¯ã¹ï¼ãã¡ã¤ã«ãµã¤ãºãå§åçã«å°ãããªãã
æå
ã®ä¾ã§è¨ãã¨ï¼æ§å½¢å¼ã®100ã¡ã¬ã®.xlsãã¡ã¤ã«ã2007å½¢å¼ã§ä¿åãç´ããã¨ããï¼2MBã®.xlsxãã¡ã¤ã«ã«ãªã£ãã
ç´50åã®ï¼ã§ããã
Excel2007ã§ã¯2003ã®æ§å½¢å¼ã®ãã¡ã¤ã«ãéããï¼äºæã¢ã¼ãï¼ãäºæã¢ã¼ãã§ã¯65000è¡ã¾ã§ããæ±ããªãã
äºæã¢ã¼ãã®ç¶æ
ãã2007ã®æ°å½¢å¼ã«ä¿åãç´ããã¨ãã¯ï¼ãã£ãããã¡ã¤ã«ãéããªããäºã§ï¼104ä¸ä»¶ã®ãã¼ã¿ãæ±ããããã«ãªãã
ãã®ããã«ï¼å¤§éã®ãã¼ã¿ãæ軽ã«æ±ãããå ´åï¼Excel2007ã®å°å ¥ãå¹æçã§ããã
ãããExcel2007ãæå ã«ãªãå ´åã§ãï¼ãã¯ãä¸è¿°ããããã«è¤æ°ã·ã¼ãã«åãã¦ãã¼ã¿ããã£ã«ããããã«èª¿ç¯ããã°ããã
(ï¼)ãä½æ¥åã«ï¼èªåä¿åããªãã«ãã¹ã
ããã¯å¤§ããªãã¡ã¤ã«ãæ±ãæã®åºæ¬ã«ãªããä½è¨ãªå¦çã¯çºçãããªãã®ãããã
ãã£ããããã¨ï¼æ¥ã«èªåä¿åãå§ã¾ãï¼æ°åéã»ã©PCãåºã¾ãã¨ããäºæ ãç¹°ãè¿ãããï¼æå PCã®ã¡ã¢ãªçæ§è½ã«ããããï¼
Excel2007ã§ã¯ï¼å·¦ä¸ã®Officeãã¿ã³ããï¼Excelã®ãªãã·ã§ã³âä¿åâãã®ããã¯ã®èªåä¿åãè¡ããªã ã«ãã§ãã¯ãå
¥ããã°ããã
(ï¼)ãï¼ã¤ã®ã¨ã¯ã»ã«ãã¡ã¤ã«ã«ï¼ã¤ã®ãã¼ãã«ã ããå ¥ããã¹ã
ãã¼ã¿ãµã¤ãºã«ããããï¼ä»¶æ°ãå¤ãå ´åã¯ï¼ãã¼ãã«ã«ã¤ãï¼ã¤ã®.xlsxãã¡ã¤ã«ãç¨æããäºãæã¾ããã
ä¸é¨ã®ãã¼ã¿ã®ä¿®æ£ãå¿
è¦ã«ãªããã³ã«ï¼éããã¡ã¤ã«ãéããªããã¨ããã®ã¯æéã®ç¡é§ã«ãªãã
(ï¼)ããã¼ã¿ã®å¨ææ§ã»é段æ§ãç解ãã¹ã
ãã¼ã¿å ¥åã®éã«ã¯ï¼ä¸è¨ã®é¢æ°ãä½éã«ãçµã¿åããããã¨ã«ãªãã
ããã«ï¼A4ã®ã»ã«ã«ã¬ã³ã¼ãã®IDãå
¥ã£ã¦ããã¨ããã
- ã«ã©ã å ã 1 ãã n ã®å¨æãã¼ã¿ã®å ´åï¼ mod( A4 - 1, n ) + 1
Aåã«ã¬ã³ã¼ãã®IDï¼ä¸»ãã¼ï¼ãæ ¼ç´ããã¦ããï¼ãã®IDã«åãã㦠1,2,3, ...., n, 1,2,3, ...., n, ã¨ãããã¼ã¿ãçæãããã¨ããã
åç´ã«ãmod( A4, n ) ãã¨ããã ãã§ã¯ï¼n åç®ã®ãã¼ã¿ã¯ n ã§ã¯ãªãï¼0 ã«ãªã£ã¦ãã¾ãã
ãããé¿ããããã«ï¼å
ã«ï¼å¼ãã¦ããï¼ãã¨ã§ï¼è¶³ãç´ãã®ã§ããã
- æ´æ°å¤ãã¨ã³ã¨ã³ã«å¢å ããå ´åï¼ ceiling( A4 / 2, 1 )
ãã®å ´åï¼IDã 1,2,3,4,... ã¨å¢å ããã®ã«åããã¦ï¼ 1,1,2,2,... ãªãå¢å åãä½ããã¨ãã§ããã
ããããçµã¿åããã¦ï¼ä¾ãã°ã1,1,2,2,3,3,1,1,2,2,3,3,... ã¨ããå¨æçãªä¸¦ã³ãä½ããããªãï¼é¢æ°ãçµã¿åããã¦
= mod( ceiling( A4 / 2, 1 ) - 1, 3 ) + 1
ã¨ããã
(ï¼)ããã¯ãã§ãã£ã«ãã¹ã
ãã£ã«ãè¡ãªãæ¹æ³ã¯ããã¤ãããã
- é¸æé åã®å³ä¸ããã¦ã¹ã§ãã©ãã°ãã¦ï¼é åãåºããæ¹æ³ã
æ°åä¸ä»¶ã®ãã£ã«ãè¡ãªãããã«ã¯ï¼æ°åã10åéãã£ã¨ãã¦ã¹ãæ¼ããã¦ããå¿
è¦ãããã
- ãã¼ãã¼ãã·ã§ã¼ãã«ãããå©ç¨ããæ¹æ³ã
ä¾ãã°ï¼Ctrlï¼ä¸ãã¼ã§ã·ã¼ãã®ä¸çªä¸ã«ã¸ã£ã³ãããæ©è½ã使ã£ã¦ï¼Shiftï¼Ctrlï¼ä¸ãã¼ã§ï¼åãæçµè¡ã¾ã§é¸æããã
ãã®å¾ï¼Excel2007ã®ãªãã³ä¸ã§ï¼ãã¼ã âç·¨éâãã£ã«âé£ç¶ãã¼ã¿ã®ä½æï¼ãé¸ã¶ãããã¨ãã£ã«ãçµããã
- ãã¯ããå©ç¨ããæ¹æ³ã
ãã®å ´åï¼ä»¶æ°ã®èª¿æ´ãéä¸çµéåºåãªã©ï¼æ§ã ãªã«ã¹ã¿ãã¤ãºãã§ããã
AutoFillã¡ã½ãããå©ç¨ãã¦ãã£ã«ãè¡ãªã£ã¦ããããã¯ãã次è¨äºã«æ²è¼ããã
Excelã·ã¼ãä¸ã§æå®é åããªã¼ããã£ã«ããVBAãã¯ã
http://d.hatena.ne.jp/language_and_engineering/20080929/1222698371
ãã®å ´åï¼æè¦æéã¯
- 35ã«ã©ã ã§12ä¸ã¬ã³ã¼ãã¯3ç§
- 10ã«ã©ã ã§24ä¸ã¬ã³ã¼ãã¯9ç§
- 70ã«ã©ã ã§50ä¸ã¬ã³ã¼ãã¯68ç§
- ãã®æ¬¡ã®50ä¸ã¬ã³ã¼ãã¯133ç§ï¼å¤§ããªIDå¤ãæ±ã£ããããï¼
ã¨ãã£ããã®ã«ãªã£ãã
Excel2007ã§ã¯ï¼ãªãã³ä¸ã®éçºã¿ããããã¯ããé¸æãï¼é¢æ°åãé©å½ã«å
¥åãã¦ä½æãé¸æããã¨ï¼Visual Basicã®ã¨ãã£ã¿ãç¾ããã
ãã®ã¨ãã£ã¿ä¸ã«é¢æ°ãæ¸ãã¦ããã°ï¼ã·ã¼ãä¸ã§å度ãã¯ãã®ã¦ã£ã³ãã¦ãéãäºã«ããï¼ãã®é¢æ°ãå®è¡ã§ããã
ï¼é¢æ°ã¯Visual Basicã¨ãã£ã¿ä¸ã«æ¸ãã¦ããã ãã§ããï¼ä¿åããå¿
è¦ã¯ãªãããã¯ããä¿åãããã¨ããã¨ï¼å¤§éã®ãã¼ã¿ã¨ä¸ç·ã«ãã¯ããä¿åãããã¨ãããã®ã ããï¼æéãããã£ã¦ãã¾ããï¼
(ï¼)ãcsvã«ã¨ã¯ã¹ãã¼ããã¹ã
ãã¼ã¿ãããã£ããï¼ãããDBã«ã¤ã³ãã¼ãããããã ãï¼DMLæãä½ãã®ã«è¦å´ããå¿ è¦ã¯ãªãã
ä¾ãã°ãã®ãããªãã¼ã«ãããã
ã¤ã³ãµã¼ãæãçæãããã¯ã
http://sugarmemo.blog7.fc2.com/blog-entry-5.html
ãããï¼ãã£ããSQLã«å¤æãããï¼ãã®ãã¡ã¤ã«ãå¦çã§ãããã¼ã«ã¯éããããã®ã«ãªããã¾ããã¡ã¤ã«ãµã¤ãºãããªãå¢ããã
æ±ç¨çã«å©ç¨ã§ããå½¢å¼ã¨ãã¦ï¼ããã¯ãã¼ã¿ãCSVã«å¤æããã®ãããã
Excelã®ä¿åã¡ãã¥ã¼ã§ã«ã³ãåºåãã®CSVå½¢å¼ãé¸ã³ï¼ä¿åå¾ï¼csvã®å é ã¨æ«å°¾ã«ä½è¨ãªç©ºè¡ãæ··å ¥ãã¦ããªããã©ããï¼å¿µã®ããéãã¦ç¢ºãããï¼ã¨ãã£ã¿ã§éãã¦ç¢ºãããã°ããï¼ã
csvã«ããã°ï¼DBå´ããã¼ãã«ä¸ã®åã«åããã¦é©å®insertãã¦ãããã®ã§ããã
ããã§ã¯ä¾ã¨ãã¦ï¼PostgreSQLã®ã¹ãã¼ãä¸ã«CSVããã¤ã³ãã¼ãããæ¹æ³ãæ²è¼ããã
- ã³ãã³ãããã³ããããpsqlã«ãã°ã¤ã³ãã
psql -U user_name -d db_name
- \l ã§ãã¼ã¿ãã¼ã¹ä¸è¦§ã表示ï¼\q ã§çµäºã§ããã
- csvãã¡ã¤ã«ã®æåã³ã¼ãã¨ï¼ãã¼ãã«åã¨ï¼csvã®çµ¶å¯¾ãã¹ãæå®ãï¼ã¤ã³ãã¼ãããã
SET client_encoding TO 'SJIS';
copy tablename from 'D:/temp/a.csv' with csv;
ãã¡ããï¼ãã®copyã³ãã³ãããã¼ãã«ã®æ°ã ãæã¡è¾¼ãå¿ è¦ãããããã ãï¼ææ¸ãã§æ¸ãå¿ è¦ã¯ãªãã
ã¯ããããï¼xlsãã¡ã¤ã«ãcsvã«æ¸ãåºãéã«ããã¼ãã«å.csvãã¨ããååã«ãã¦ããã
ããã¦ï¼ãã¼ãã«å®ç¾©æ¸ãããã¼ãã«åã縦ä¸åã§ã³ãã¼ãï¼æ°è¦ã¨ã¯ã»ã«ã·ã¼ãã«è²¼ãä»ããã
ãã¨ã¯ï¼ãã®è²¼ãä»ãããã¼ãã«åä¸è¦§ããï¼csvåã ' &".csv" ' ã«ããçæãï¼copyæãå ¨ãã¼ãã«ã®åã ãä¸æ¬ã§ä½ãã ãã ã
æçµçã«
delete from TABLENAME; copy TABLENAME from 'D:/temp/TABLENAME.csv' with csv;
ã¨ããè¡ãå ¨ã¦ã®ãã¼ãã«ã«ã¤ãã¦ä¸¦ã¹ã°ããããããã³ãã³ãããã³ããã«è²¼ãä»ããäºã«ãã£ã¦ï¼ãã¼ã¿ã®ã¤ã³ãã¼ããçµããã
ãªããããã¼ã¿ä»¶æ°ãå¤ãããã«ï¼1ãã¼ãã«ã§csvãã¡ã¤ã«ã2ã¤ä»¥ä¸ã«åããã¦ãã¾ãå ´åã¯ï¼ãã®äºãèæ ®ãã¦copyæãçæããå¿ è¦ãããã
ãªãï¼ã·ã¼ãä¸ã®ãã¼ã¿ãODBCçµç±ã§ï¼ã·ã¼ãããç´æ¥DBã«ã¤ã³ãã¼ãããã¨ããæ¹æ³ãä¸å¿ãããï¼ãã¡ãã¯ãããæéããããã
ç´ æ©ãæ¸ã¾ããããã«ã¯ï¼ãã®ããã«DBå´ãã¤ã³ãã¼ãæ段ã¨ãã¦ç¨æãã¦ããã¦ããæ¹æ³ã使ãã®ãããã ããã
ã¾ã¨ã
- Excelã§ãã¼ã¿ãä½ãã¹ããï¼ç´æçãªæä½æ§ï¼
- ã§ããã° Excel㯠2007 ã使ãã¹ããï¼100ä¸è¡ï¼
- ä½æ¥åã«ï¼èªåä¿åããªãã«ãã¹ããï¼ä½è¨ãªå¦çãã«ããï¼
- ï¼ã¤ã®ã¨ã¯ã»ã«ãã¡ã¤ã«ã«ï¼ã¤ã®ãã¼ãã«ã ããå ¥ããã¹ããï¼ä½è¨ãªæéãã«ããï¼
- ãã¼ã¿ã®å¨ææ§ã»é段æ§ãç解ãã¹ããï¼ä¸¦ã³ãä½ãé¢æ°ï¼
- ãã¯ãã§ãã£ã«ãã¹ããï¼éãï¼ã«ã¹ã¿ãã¤ãºæ§ï¼
- csvã«ã¨ã¯ã¹ãã¼ããã¹ããï¼éãï¼æ±ç¨æ§ï¼
ä¸è¨ã«ãã¹ããã¼ã¿ãä½ãã®ã«å½¹ç«ã¤é¢æ°ãªã©ãã¾ã¨ããé¢é£è¨äºãããã
Webãµã¼ãã¹ã¨Excelãä½µç¨ãã¦CSVå½¢å¼ã®ãã¹ããã¼ã¿ãä½ã
http://mitc.xrea.jp/diary/072
- æ¥ä»ãä½ãå ´åã® date( 2008, 12, 31 )
- æ¥ä»å½¢å¼ãå å·¥ããå ´åã® text( "2008/12/31", "yyyy-mm-dd" ) & " 00:00:00"
ãªã©ããã使ãã
é¢é£ããè¨äºï¼