ã¯ããã«
ãCSVãã¡ã¤ã«ã¯æãæ®åãããã¼ã¿äº¤æç¨ãã©ã¼ãããã§ããããã¾ãã¾ãªæ¹è¨ãããã¾ãã
ãæ¬ç¨¿ã§ã¯CSVãã¡ã¤ã«ãã©ã¼ãããã®ä»æ§ã¨ãã¼ã¿äº¤ææã®ãã¤ã³ãã説æãã¾ãã
対象èªè
ãCSVãã¡ã¤ã«ãæ±ãDB管çè ãéçºè ã
CSVã¨ã¯ï¼
ãCSVã¨ã¯Comma-Separated Valuesã®ç¥ã§ãã«ã³ãåºåãã§ä¸¦ã¹ãå¤ã¨ããæå³ã§ãã
ãCSVãã¡ã¤ã«ã®ä¾ã¨ãã¦ãä¸è¬çãªã¢ãã¬ã¹å¸³ãã¼ã¿ã示ãã¾ãã
"å§","å","çå¹´ææ¥","éµä¾¿çªå·","ä½æ","é»è©±çªå·" "å±±ç°","太é","2001/1/1","100-0002","æ±äº¬é½å代ç°åºçå± å¤è","03-1234-5678" "å±±ç°","次é","2001/1/2","251-0036","ç¥å¥å·çè¤æ²¢å¸æ±ã®å³¶ï¼ä¸ç®","03-9999-9999"
ãã«ã³ãã§åºåããããã¼ã¿ã®æ¨ªä¸åã"è¡"ï¼è±ï¼Rowï¼ã縦ä¸åã"å"ï¼è±:Columnï¼ã¨å¼ã³ã¾ããå é è¡ã¯ååã®ã¿ã¤ãã«ã§ãã
ãã¡ã¤ã«ãã©ã¼ãããä»æ§
ãã¡ã¤ã«å½¢å¼
ããã¡ã¤ã«ã¯ããã¹ãå½¢å¼ã§ãã
æåã³ã¼ã
ãè¦å®ã¯ããã¾ããããæ¥æ¬ã§ã¯ä¸»ã«Shift_JISãä»ã«EUCãUnicodeãªã©ã使ãã¾ãã
ãããè¡ã®æç¡
ãæåã®1è¡ããã¼ã¿ã§ã¯ãªããåã«ã©ã ã®ã¿ã¤ãã«ã«ãªã£ã¦ããå ´åãããã¾ããããããããã¨å¼ã³ã¾ãã
"å§","å","çå¹´ææ¥","éµä¾¿çªå·","ä½æ","é»è©±çªå·"
ã使ãå´ãåã«ã©ã ã®æå³ãèªèãã¦ããã®ã§ããã°ããã£ã¦ããªãã¦ããã¾ãã¾ããããä»ã·ã¹ãã ã¨ã®ãã¼ã¿äº¤ææã«ã¯ãããããä»ãããä»ããªããã®åã決ããå¿ è¦ã§ãã
åºåãæåã®ç¨®é¡
ãCSVã¯ã,ãï¼ã«ã³ãï¼åºåããåºæ¬ã§ããã<TAB>ï¼ã¿ãï¼ã§åºåãå ´åãããã¾ãããããç¹ã«TSVï¼Tab-Separated Valuesï¼ã¨å¼ã³ã¾ããTSVã¯ããå©ç¨ããã¾ããããã¼ã¿å ã«<TAB>ãå«ã¾ãªããã¨ãåæã§ããããå«ãå ´åã¯ãåé¤ãããã¯ç½®æãè¡ãã¾ãã
å±±ç° <TAB> 太é <TAB> 2001/1/1 <TAB> 100-0002 <TAB> æ±äº¬é½å代ç°åºçå± å¤è
ãæ¬ç¨¿ã§ã¯ã«ã³ãåºåãã®ã¿ãæ±ãã¾ãã
ãâ»2008/06/07追è¨ï¼ã«ã³ãåºåãCSVã®Cã¯ãCommaãã§ãããã¿ãåºåãã®TSVãªã©ãã¾ã¨ãã¦ãCSVã=ãCharacter-Separated Valuesãã¨å¼ã¶ããã§ãã
æ¹è¡ã³ã¼ã
ãæ¹è¡ã³ã¼ãã¯ãã©ãããã©ã¼ã ã«ãã£ã¦ç°ãªãã¾ããä¸è¬çã«Windowsã¯<CR><LF>ãUNIXã¯<LF>ã§ãã
ãâ»2008/04/16追è¨ï¼RFCã§ã¯æ«å°¾(ã¬ã³ã¼ãã®åºåãã¨ãã¦)ã®æ¹è¡ã¯<CR><LF>ãæ¨å¥¨ãã¦ãã¾ããCSVã解éããããã°ã©ã ã§ã¯ã©ã¡ãã®æ¹è¡ã³ã¼ãã§ãèªããããã«ä½ããã¨ããå§ããã¾ãã
ãâ»2008/06/07追è¨ï¼æ¬ç¨¿ã®ã³ã¡ã³ãã§RFC4180ã¨æ¹è¡ã³ã¼ãã«é¢ãããææãããã¾ãããã ããCSVãRFC4180ããã以åã«èããããå½¢å¼ã§ããRFCãæ£ã¨ãã¦ããããã§ã¯ãªããã¨(CSVã®å®è£ ã«ã¯ãå社ç¬èªã®æ¡å¼µãå¶ç´ãããããã ããæ´å²çã«è¦ãã°ããããã®å®è£ ã®ã»ããRFC 4180以åããåå¨ãã¦ãããï¼ Wikipediaããå¼ç¨ï¼ãCSVã¯ããã¹ãã¨ãã£ã¿ã§ç·¨éã§ãããã¨èªä½ããã®ãã©ã¼ãããã®å©ç¹ã§ããèªç¶ã¨æ¹è¡ã³ã¼ãã¯ãã©ãããã©ã¼ã ã«åããããã¨ããªã©ããä¸è¨ã®è¨è¿°ã«ãªã£ã¦ãã¾ãã
ããã«ã¯ã©ã¼ã
ãCSVã§ã¯å¤ãããã«ã¯ã©ã¼ãã§å²ã¿ã¾ãã
"å±±ç°"
ãããããããã«ã¯ã©ã¼ãã使ããªãå ´åãããã¾ããããã¯å¤ã®ä¸ã«ãããã«ã¯ã©ã¼ãï¼"ï¼ããã«ã³ãï¼,ï¼ããæ¹è¡ï¼<CR>ã<LF>ï¼ããªã©ã®å¶å¾¡æåãå«ã¾ãªããã¨ããåææ¡ä»¶ãããã¾ãã
å±±ç°,太é,å¤ã®æ¹è¡ãã«ã³ããããã«ã¯ã©ã¼ãã¯åé¤ãã¾ãã
ãããããããå¤ã«å«ã¾ããå ´åã¯ã以ä¸ã®ã«ã¼ã«ãå®ãã¾ãã
- å¤ãããã«ã¯ã©ã¼ãã§å²ããã¨ã
- å¤å ã®ããã«ã¯ã©ã¼ãã¯äºéåï¼"→""ï¼ãããã¨ã
"å±±ç°","太é","å¤ã« æ¹è¡ã,ã«ã³ãã""ããã«ã¯ã©ã¼ããå«ã¾ãã¦ãåé¡ããã¾ããã"
ãå¤ã«æ¹è¡ãå«ã¾ãã¦ããCSVãããã¹ãã¨ãã£ã¿ã§è¦ãã¨ä¸æ£ãªå½¢å¼ã«è¦ãã¾ãããããã«ã¯ã©ã¼ãã§å²ã¾ãã¦ããã°ãåé¡ããã¾ããã
ãã¾ãã«CSVã®æ¹è¨ã§\ã¨ã¹ã±ã¼ããè¡ããã¨ãããã¾ãã
"å±±ç°","太é","å¤ã«æ¹è¡\nã\,ã«ã³ãã\"ããã«ã¯ã©ã¼ããå«ã¾ãã¦ãåé¡ããã¾ããã"
ããã®æ¹è¨ã¯ãã¾ãæ®åãã¦ãã¾ããã®ã§ãå©ç¨ããã®ã¯é¿ãã¾ãããã
ãã¼ã¿äº¤ææã®ãã¤ã³ã
ã©ããæ¨æºãï¼
ãç´¹ä»ããããã«CSVå½¢å¼ã«ã¯ããã¤ãã®ãã¿ã¼ã³ãããã¾ãããã®ä¸ã§ãæ¨æºã¨å¼ã¹ãã®ã¯ä»¥ä¸ã®ãã¿ã¼ã³ã§ãã
- åºåãæåã¯ã«ã³ã
- ããã«ã¯ã©ã¼ãã§å²ã¿ãå¤å ã®ããã«ã¯ã©ã¼ãã¯äºéå
- ãããè¡ã¯ä»ããªãï¼ãã ãããã¼ã¿ãExcelã§å©ç¨ããå ´åã¯ä»ããï¼
ãèªåããã¼ã¿ãã渡ãå´ããªãã°ãã®ãã¿ã¼ã³ãå®ãããåãåãå´ããªãã°åå¥ã«åã決ããããå¿ è¦ãããã¾ãã
ãã¼ã¿äº¤æã«å¿ è¦ãªåã決ã
ãCSVå½¢å¼ã§ãã¼ã¿äº¤æãè¡ãå ´åã¯ãå¿ ã以ä¸ã®é ç®ã®åã決ããè¡ã£ã¦ãã ããã
- æåã³ã¼ã
- æ¹è¡ã³ã¼ã
- ãããè¡ã®æç¡
- åºåãæå
- ããã«ã¯ã©ã¼ãã§å²ããå¦ã
- ããã«ã¯ã©ã¼ãã§å²ã¾ãªãå ´åã®å¤å ã®å¶å¾¡æå(ããã«ã¯ã©ã¼ããã«ã³ããã¿ããæ¹è¡)ã®å¦ç
ããã¼ã¿äº¤ææã«ãæåã³ã¼ããéãããæ¹è¡ãå«ã¾ãã¦ãããããã¼ã¿ã«ããããå ¥ã£ã¦ãã¾ã£ããã¨ãã失æãããèãã¾ããã注æãã
ã¾ã¨ã
ãCSVå½¢å¼ã®è©³ç´°ã¨æ±ãæ¹ã«ã¤ãã¦èª¬æãã¾ãããCSVã¯ã¨ã¦ãåºã使ããã¦ããã®ã«ãæ¹è¨ãå¤ãã説æè³æãå°ãªããåå¿è ã®å¤±æè«ã«äºæ¬ ãã¾ãããæ¬ç¨¿ãçãã¾ã®ãå½¹ã«ç«ã¦ãã°å¹¸ãã§ãã
åèè³æ
- RFC4180
ã«ãã´ãªããInformationalããæ å ±æä¾ç®çã§ãããCSVã®å ¬å¼ä»æ§ã¨èãã¦ããã§ãï¼CSVã¯å ¬å¼ä»æ§ã¨ãã¦æ¨æºåããã¦ãã¾ãããã¾ãããããäºå®ãããã¾ããï¼ã
- RFC4180(æ¥æ¬èªè¨³)
RFCã®æ¥æ¬èªè¨³ã§ãã
- How To:The Comma Separated Value (CSV) File Format
CSVã®ä»æ§ã解æãXMLã¸ã®å¤æã«ã¤ãã¦èª¬æãã¦ãã¾ãã