iwai****@users*****
iwai****@users*****
2009年 12月 7日 (月) 01:58:46 JST
Index: docs/modules/Text-CVS_XS-0.23/Text-CSV_XS-0.23.pod diff -u /dev/null docs/modules/Text-CVS_XS-0.23/Text-CSV_XS-0.23.pod:1.1 --- /dev/null Mon Dec 7 01:58:46 2009 +++ docs/modules/Text-CVS_XS-0.23/Text-CSV_XS-0.23.pod Mon Dec 7 01:58:46 2009 @@ -0,0 +1,253 @@ +=head1 åå + +Text::CSV_XS - CSVå½¢å¼ã®æä½ã«ã¼ãã³ + +=head1 æ¦è¦ + + use Text::CSV_XS; + + $csv = Text::CSV_XS->new(); # æ°ãããªãã¸ã§ã¯ããä½ã + $csv = Text::CSV_XS->new(\%attr); # æ°ãããªãã¸ã§ã¯ããä½ã + + $status = $csv->combine(@columns); # 縦åãé£çµãã¦ä¸ã¤ã®æååã«ãã + $line = $csv->string(); # é£çµãããã®æååãå¾ã + + $status = $csv->parse($line); # CSVæååããã¼ã¹ãã¦ãã£ã¼ã«ã群ã«åãåãã + @columns = $csv->fields(); # ãã¼ã¹ããããã®ãã£ã¼ã«ã群ãå¾ã + + $status = $csv->status(); # ç´åã®ã¹ãã¼ã¿ã¹ãå¾ã + $bad_argument = $csv->error_input(); # ç´åã®ä¸æ£å¼æ°ãå¾ã + + $status = $csv->print($io, $columns); # $io ãã¡ã¤ã«ã¸ã + # ãããã¾ãã£ã¼ã«ã群ãæ¸ãè¾¼ã + + $columns = $csv->getline($io); # ï¼io ãã¡ã¤ã«ããï¼è¡ãèªã¿è¾¼ã¿ããã¼ã¹ + # ããå¾ã«ãã£ã¼ã«ã群ã®é åãªãã¡ã¬ã³ã¹ãè¿ã + + $csv->types(\@t_array); # 縦åã®å½¢å¼ãè¨å®ãã + +=head1 説æ + +ã³ã³ãåºåãæåå CVS ãçµã¿ç«ã¦ããåãåãããããã®ã«ãText::CVS_XS ã¯ä¾¿å©ãªæ©è½ãæä¾ãã¾ããText::CVS_XS ã¯ã©ã¹ã®ã¤ã³ã¹ã¿ã³ã¹ã§ã¯ããã£ã¼ã«ã群ãé£çµã㦠CSV æååã«ãããããã®å対ã«CSVæååããã¼ã¹ãã¦ãã£ã¼ã«ã群ã«ãããã¨ãã§ãã¾ãã + + +=head1 é¢æ°ç¾¤ + +=over 4 + +=item version() + +(ã¯ã©ã¹ã¡ã½ãã) 使ç¨ãã¦ããã¢ã¸ã¥ã¼ã«ã®ãã¼ã¸ã§ã³ãè¿ãã + +=item new(\%attr) + +(ã¯ã©ã¹ã¡ã½ãã) æ°ãã Text::CSV_XS ã¤ã³ã¹ã¿ã³ã¹ãè¿ãããªãã¸ã§ã¯ãã®å±æ§å¤ã¯ãããã·ã¥ãªãã¡ã¬ã³ã¹ C<\%attr> ã§ï¼éæã«ï¼æå®ããã次ã®å±æ§å¤ãæå®ã§ããï¼ + +=over 8 + +=item quote_char + +空ç½æåãå«ããã£ã¼ã«ããã¯ãªã¼ãããããã®æåã§ãããã©ã«ãã¯äºéå¼ç¨ç¬¦ (C<">)ãundef ãæå®ããã¨ãæååãã¯ãªã¼ããããªãï¼ç©ºç½æåã使ããªããããªç°¡ç´ ãªå ´åã®ã¿ä½¿ç¨ãããã¨ï¼ã + +=item eol + +横è¡ã«å ããè¡ã®çµããã示ãæåã§ãä¸è¬çã«ã¯ C<undef> ï¼ç¡ãããã©ã«ãï¼ã C<"\012"> (ã©ã¤ã³ãã£ã¼ã) ããã㯠C<"\015\012"> (ãã£ãªãã¸ãªã¿ã¼ã³+ã©ã¤ã³ãã£ã¼ã) ã§ããã + +=item escape_char + +ã¯ãªã¼ããããã£ã¼ã«ãã®ä¸ã§ã¨ã¹ã±ã¼ããæ½ãæåã§ãããã©ã«ãã§ã¯ã¯ãªã¼ãæå (C<">) ã¨åãã + +=item sep_char + +ãã£ã¼ã«ããåºåãæåã§ãããã©ã«ãã¯ã³ã³ã (C<,>)ã + +=item binary + +ãã®å±æ§å¤ãç (TRUE) ãªãã°ãã¯ãªã¼ããããã£ã¼ã«ãã®ä¸ã§ãã¤ããªæåã使ç¨ãããã¨ãã§ããããã®ãã¤ããªæåã«ã¯ã©ã¤ã³ãã£ã¼ãããã£ãªãã¸ãªã¿ã¼ã³ããã㦠NUL ãã¤ããå«ã¾ãã¦ããï¼ NUL ãã¤ã㯠C<"0> ã¨ãã¦ã¨ã¹ã±ã¼ãããªãã¦ã¯ãªããªãï¼ãããã©ã«ãã§ããã®æ©è½ã¯ãªãã + +=item types + +ã«ã©ã ã®å½¢å¼ï¼ãã®å±æ§å¤ã¯ãããã¾å¾è¿°ã® I<types> ã¡ã½ããã«æ¸¡ããããI<types> ã¡ã½ããã使ç¨ããå ´åãé¤ãããã®å±æ§å¤ãè¨å®ãã¦ã¯ãªããªãã詳ããã¯ãå¾è¿°ã® I<types> ã¡ã½ããã®èª¬æãåç §ã + +=item always_quote + +ãã£ã¼ã«ãå ã®ããã¹ããåºåãæåãå«ããããªå ´åãªã©ããã®å¿ è¦ãããéã«ã®ã¿ããã©ã«ãã§ã¯ãã£ã¼ã«ãã¯ã¯ãªã¼ãã§åºåãããããã®å±æ§å¤ãç TRUE ã«è¨å®ããã¨ãå ¨ã¦ã®ãã£ã¼ã«ããã¯ãªã¼ããããããã®æ©è½ã¯å¤é¨ã¢ããªã±ã¼ã·ã§ã³ãç¨ããå ´åã«ä¾¿å©ã§ãããï¼ Text::CVS_XS ã使ããªãå¯åæ³ãªããã°ã©ãã®ããã«ã:-) + +=back + +ããããã¾ã¨ããã¨ã + + $csv = Text::CSV_XS->new(); + +ã¯ã以ä¸ã¨åãã§ããï¼ + + $csv = Text::CSV_XS->new({ + 'quote_char' => '"', + 'escape_char' => '"', + 'sep_char' => ',', + 'binary' => 0 + }); + +=item combine + + $status = $csv->combine(@columns); + +ãã®ãªãã¸ã§ã¯ãé¢æ°ã¯ãå¼æ°ãã CVS æååãçµã¿ç«ã¦ãæåã失æã®ã¹ãã¼ã¿ã¹ãè¿ãã失æããã®ã¯ãããããå¼æ°ã足ããªããä¸æ£ãªæååãå¼æ°ãå«ãããã§ããããæåããå ´åã C<string()> ã«ãã£ã¦çµã¿ç«ã¦ã CSV æååãå¾ããã¨ãã§ããã失æããå ´åãC<string()> 㯠æªå®ç¾©ãè¿ã C<error_input()> ã«ãã£ã¦ç¡å¹ã ã£ãå¼æ°ãå¾ããã¨ãã§ããã + +=item print + + $status = $csv->print($io, $columns); + +combine ã¨ä¼¼ã¦ãããããã®ã¡ã½ããã¯é åãªãã¡ã¬ã³ã¹ï¼é åã§ã¯ãªãï¼ãå ¥åããããã¨ãæå¾ ããï¼çµã¿ç«ã¦ã CSV æååãã¾ã£ããä½ããªãï¼I<$io> ãªãã¸ã§ã¯ãã¸ç´ã¡ã«æ¸ãè¾¼ããããã§ãI<print> ã¡ã½ããã«ä¸ããã®ã¯é常ãI<$io> ãªãã¸ã§ã¯ãã é¡ä¼¼ããä»ã®ãªãã¸ã§ã¯ãã§ããã注æãã¹ãäºã¨ãã¦ããã®å¼ã³åºãã§æ¬¡ã®æ¹æ³ã¯ééãã§ããï¼ + + + open(FILE, ">whatever"); + $status = $csv->print(\*FILE, $columns); + +C<\*FILE> ã°ããã¯ãªãã¸ã§ã¯ãã§ã¯ãªãã®ã§ãprint ã¡ã½ãããå®è¡ãããã¨ãã§ããªãã解決æ¹æ³ã¯ IO:File ãªãã¸ã§ã¯ãã使ç¨ããã IO::Wrap ãªãã¸ã§ã¯ãã®ä¸ã¸ã°ãããé è½ãã¦ãã¾ããã¨ã§ããã詳細ã¯ãL<IO::File(3)> 㨠L<IO::Wrap(3)> ãåç §ã + +ããã©ã¼ãã³ã¹ä¸ã®çç±ããããã® print ã¡ã½ããã¯çµã¿ç«ã¦ã CSV æååãå¤é¨ã¸æä¾ããªããã¨ããã I<$csv-E<gt>string()>, I<$csv-E<gt>status()>, I<$csv->fields()>, ãã㦠I<$csv-E<gt>error_input()> ã¯ããã®ã¡ã½ããã®å¾ã§æå³ããªããªãã + +=item string + + $line = $csv->string(); + +ãã®ãªãã¸ã§ã¯ãé¢æ°ã¯ã C<parse()> ã¸ã®å ¥åãããã®ã C<combine()> ã§çµã¿ç«ã¦ããã CSV æååãããããä½ã§ããç´åã®ãã®ãè¿ãã + +=item parse + + $status = $csv->parse($line); + +ãã®ãªãã¸ã§ã¯ãé¢æ°ã¯ CSV æååããã£ã¼ã«ãã«åãåãã¦ããããå¾ã«æåã失æã®ã¹ãã¼ã¿ã¹ãè¿ãã失æããã®ã¯ãå¼æ°ã®ä¸è¶³ãä¸ãããã CSV æååãä¸é©åãªãã©ã¼ãããã ããã§ããããæåããå ´åã«ã¯ãC<fields()> ã¡ã½ããã«ãã£ã¦åãåãããããã£ã¼ã«ããå¾ãããã失æã®å ´åã«ã¯ã C<fields()> ã¯æªå®ç¾©å¤ãè¿ã C<error_input()> ã«ãã£ã¦ä¸æ£ãªå¼æ°ãå¾ããã¨ãã§ããã + +ã«ã©ã ã®å½¢å¼ãè¨å®ããããã«ãI<types()> ã¡ã½ããã使ãã¹ãã§ãããå¾è¿°ã®èª¬æãåç §ã + + +=item getline + + $columns = $csv->getline($io); + +ãã㯠print ã¨å¯¾ããªããã®ã§ãparse ã combine ã®å¯¾ã¨ãªããããªãã®ã ï¼ IO ãªãã¸ã§ã¯ã $IOã«ãã㦠$IO->getline() ãç¨ãã¦ï¼è¡ãèªã¿åºãããã®ï¼è¡ããã¼ã¹ãã¦é åãªãã¡ã¬ã³ã¹ã«ç´ããããã®é åãªãã¡ã¬ã³ã¹ãè¿ããããã失æããå ´åã«ã¯ undef ãè¿ãããã + +ç¹°ãè¿ãã«ãªããã I<$csv-E<gt>string()>, I<$csv-E<gt>fields()>, ãã㦠I<$csv-E<gt>status()> ã¡ã½ããã¯ãã®ã¡ã½ããã®å¾ã§ã¯æå³ããªããªãã + +=item types + + $csv->types(\@tref); + +ãã®ã¡ã½ããã¯ã縦è¡ãæå®ãããå½¢å¼ã¸å¼·å¶çã«å¤æããã®ã«ç¨ããããã¨ãã°ãæ´æ°å¤ã§è¡¨ç¾ãããï¼ã«ã©ã ãå精度æ°å½¢å¼ã®ï¼ã«ã©ã ãæååã®ï¼ã«ã©ã ããã£ãå ´åã¯ã次ãå®è¡ãããã¨ã«ãªãã ãã + + $csv->types([Text::CSV_XS::IV(), + Text::CSV_XS::NV(), + Text::CSV_XS::NV(), + Text::CSV_XS::PV()]); + +ã«ã©ã å½¢å¼ããã³ã¼ãããã¨ãã®ã¿ãè¨ãæãã㨠I<parse()> 㨠I<getline()> ã¡ã½ããã使ãã¨ãã«ã®ã¿ããã®ã«ã©ã å½¢å¼ãç¨ããããã + + +ã«ã©ã ã¿ã¤ãã解é¤ããã®ã¯æ¬¡ã®ããã«ãã + + $csv->types(undef); + +ãããã¯ã¾ããç¾å¨ã®å½¢å¼ãå¾ãã«ã¯æ¬¡ã®æ¹æ³ãæ¡ã + + $types = $csv->types(); + +=item fields + + @columns = $csv->fields(); + +ãã®ãªãã¸ã§ã¯ãé¢æ°ã¯ã C<combine()> ã¸ã®å ¥åå¤ã C<parse()> ããå¾ãããåãåãããããã£ã¼ã«ã群ãããããä½ã§ããç´åã®ãã®ãè¿ãã + +=item status + + $status = $csv->status(); + +This object function returns success (or failure) of C<combine()> or +C<parse()>, whichever was called more recently. +ãã®ãªãã¸ã§ã¯ãé¢æ°ã¯ã C<combine()> ã C<parse()> ããããä½ã§ããç´åã®ã¡ã½ãããæåï¼ãããã¯å¤±æï¼ãããã©ãããè¿ãã + +=item error_input + + $bad_argument = $csv->error_input(); + +ãã®ãªãã¸ã§ã¯ãé¢æ°ã¯ãC<combine()> ã C<parse()> ãããããä½ã§ããç´åã®ã¡ã½ãããã¨ã©ã¼ã¨ãªã£ãå¼æ°ï¼ããããã°ï¼ãè¿ãã + +=back + +=head1 ä¾ + + require Text::CSV_XS; + + my $csv = Text::CSV_XS->new; + + my $column = ''; + my $sample_input_string = '"I said, ""Hi!""",Yes,"",2.34,,"1.09"'; + if ($csv->parse($sample_input_string)) { + my @field = $csv->fields; + my $count = 0; + for $column (@field) { + print ++$count, " => ", $column, "\n"; + } + print "\n"; + } else { + my $err = $csv->error_input; + print "parse() failed on argument: ", $err, "\n"; + } + + my @sample_input_fields = ('You said, "Hello!"', + 5.67, + 'Surely', + '', + '3.14159'); + if ($csv->combine(@sample_input_fields)) { + my $string = $csv->string; + print $string, "\n"; + } else { + my $err = $csv->error_input; + print "combine() failed on argument: ", $err, "\n"; + } + +=head1 注æ + +ãã®ã¢ã¸ã¥ã¼ã«ã¯çå®ä¸ã® CVS ãã©ã¼ããããå ã«ãã¦ãããããã®ãã©ã¼ããããæãä¸è¬çãªãã®ã¨ã¯è¨ãé£ããããããªãã + +=over 4 + +=item 1 + +CVS ãã£ã¼ã«ãã®ä¸ã«ç´ãããã¨ãã§ããæåã«ã¯ã 0x09 (tab) 㨠of 0x20 (space) ãã 0x7E (tilde)ã®å æ¬çãªç¯å²ã¨ãå«ãããã¤ããªã¢ã¼ãã§ã¯ã¯ãªã¼ãããããã£ã¼ã«ãã®ä¸ã«ããã¦å ¨ã¦ã®æåãåãä»ããã + +=item 2 + +CSV ã®ãã£ã¼ã«ãã¯ãäºéå¼ç¨ç¬¦ï¼quote charï¼ã§æã¾ããã¹ãã§ããã + +=item 3 + +CVS ã®ãã£ã¼ã«ãã®ä¸ã«ã³ã³ã(separator char)ãããå ´åã¯ãäºéå¼ç¨ç¬¦ã§æã¾ããªããã°ãªããªãã + +=item 4 + +CVS ãã£ã¼ã«ãã®ä¸ã«äºéå¼ç¨ç¬¦ãåãè¾¼ãå ´åã¯ãä¸å¯¾ã¨ãªã£ãäºéå¼ç¨ç¬¦ã®éã«æã¾ããªããã°ãªããªãããã¤ããªã¢ã¼ãã§ã¯ç¹ã«ã NUL ãã¤ãã示ã C<"0> ãç¨ããã¹ãã§ããã + +=item 5 + +CSV æååã¯ã 0x0A (ã©ã¤ã³ãã£ã¼ã) ããã㯠0x0D + 0x0A(ãã£ãªãã¸ãªã¿ã¼ã³ + ã©ã¤ã³ãã£ã¼ã)ã§çµããã¹ãã§ããã + +=head1 AUTHOR + +Alan Citterman F<E<lt>alan****@mfgrt*****<gt>> ãããã® Perl ã¢ã¸ã¥ã¼ã«ãæåã«æ¸ãããAlan 㸠Text::CSV_XS ã«é¢ããã¡ã¼ã«ãã©ããéããªãã§æ¬²ããããªããªããä»ã§ã¯ãã®ã¢ã¸ã¥ã¼ã«ã®ä¸»è¦é¨åãå ãã C ã³ã¼ãé¨åã«ã¤ãã¦ãå½¼ã¯é¢ä¸ãã¦ããªãããã§ããã + +Jochen Wiedmann F<E<lt>joe****@ispso*****<gt>> ããã¨ã³ã³ã¼ãã¨ãã³ã¼ãã®ã«ã¼ãã³ãæéç¶æ ãã·ã³ãå®è£ ãã C ã³ã¼ãã§æ¸ãç´ããã¯ãªã¼ããã¨ã¹ã±ã¼ããããã¦ã»ãã¬ã¼ã¿ã¼æåå¤æ°ããã¤ããªã¢ã¼ãããã㦠print 㨠getline ã¡ã½ãããå ããã + +=head1 SEE ALSO + +L<perl(1)>, L<IO::File(3)>, L<IO::Wrap(3)> + +=head1 Translator into Japanese (翻訳è ) + +anahori (at users.sourceforge.jp) + +Japanized Perl Resources Project (L<http://sourceforge.jp/projects/perldocjp/>) + +=cut \ No newline at end of file Index: docs/modules/Text-CVS_XS-0.23/Text-CVS_XS-0.23.pod diff -u docs/modules/Text-CVS_XS-0.23/Text-CVS_XS-0.23.pod:1.1 docs/modules/Text-CVS_XS-0.23/Text-CVS_XS-0.23.pod:removed --- docs/modules/Text-CVS_XS-0.23/Text-CVS_XS-0.23.pod:1.1 Sat Aug 13 20:14:50 2005 +++ docs/modules/Text-CVS_XS-0.23/Text-CVS_XS-0.23.pod Mon Dec 7 01:58:46 2009 @@ -1,253 +0,0 @@ -=head1 åå - -Text::CSV_XS - CSVå½¢å¼ã®æä½ã«ã¼ãã³ - -=head1 æ¦è¦ - - use Text::CSV_XS; - - $csv = Text::CSV_XS->new(); # æ°ãããªãã¸ã§ã¯ããä½ã - $csv = Text::CSV_XS->new(\%attr); # æ°ãããªãã¸ã§ã¯ããä½ã - - $status = $csv->combine(@columns); # 縦åãé£çµãã¦ä¸ã¤ã®æååã«ãã - $line = $csv->string(); # é£çµãããã®æååãå¾ã - - $status = $csv->parse($line); # CSVæååããã¼ã¹ãã¦ãã£ã¼ã«ã群ã«åãåãã - @columns = $csv->fields(); # ãã¼ã¹ããããã®ãã£ã¼ã«ã群ãå¾ã - - $status = $csv->status(); # ç´åã®ã¹ãã¼ã¿ã¹ãå¾ã - $bad_argument = $csv->error_input(); # ç´åã®ä¸æ£å¼æ°ãå¾ã - - $status = $csv->print($io, $columns); # $io ãã¡ã¤ã«ã¸ã - # ãããã¾ãã£ã¼ã«ã群ãæ¸ãè¾¼ã - - $columns = $csv->getline($io); # ï¼io ãã¡ã¤ã«ããï¼è¡ãèªã¿è¾¼ã¿ããã¼ã¹ - # ããå¾ã«ãã£ã¼ã«ã群ã®é åãªãã¡ã¬ã³ã¹ãè¿ã - - $csv->types(\@t_array); # 縦åã®å½¢å¼ãè¨å®ãã - -=head1 説æ - -ã³ã³ãåºåãæåå CVS ãçµã¿ç«ã¦ããåãåãããããã®ã«ãText::CVS_XS ã¯ä¾¿å©ãªæ©è½ãæä¾ãã¾ããText::CVS_XS ã¯ã©ã¹ã®ã¤ã³ã¹ã¿ã³ã¹ã§ã¯ããã£ã¼ã«ã群ãé£çµã㦠CSV æååã«ãããããã®å対ã«CSVæååããã¼ã¹ãã¦ãã£ã¼ã«ã群ã«ãããã¨ãã§ãã¾ãã - - -=head1 é¢æ°ç¾¤ - -=over 4 - -=item version() - -(ã¯ã©ã¹ã¡ã½ãã) 使ç¨ãã¦ããã¢ã¸ã¥ã¼ã«ã®ãã¼ã¸ã§ã³ãè¿ãã - -=item new(\%attr) - -(ã¯ã©ã¹ã¡ã½ãã) æ°ãã Text::CSV_XS ã¤ã³ã¹ã¿ã³ã¹ãè¿ãããªãã¸ã§ã¯ãã®å±æ§å¤ã¯ãããã·ã¥ãªãã¡ã¬ã³ã¹ C<\%attr> ã§ï¼éæã«ï¼æå®ããã次ã®å±æ§å¤ãæå®ã§ããï¼ - -=over 8 - -=item quote_char - -空ç½æåãå«ããã£ã¼ã«ããã¯ãªã¼ãããããã®æåã§ãããã©ã«ãã¯äºéå¼ç¨ç¬¦ (C<">)ãundef ãæå®ããã¨ãæååãã¯ãªã¼ããããªãï¼ç©ºç½æåã使ããªããããªç°¡ç´ ãªå ´åã®ã¿ä½¿ç¨ãããã¨ï¼ã - -=item eol - -横è¡ã«å ããè¡ã®çµããã示ãæåã§ãä¸è¬çã«ã¯ C<undef> ï¼ç¡ãããã©ã«ãï¼ã C<"\012"> (ã©ã¤ã³ãã£ã¼ã) ããã㯠C<"\015\012"> (ãã£ãªãã¸ãªã¿ã¼ã³+ã©ã¤ã³ãã£ã¼ã) ã§ããã - -=item escape_char - -ã¯ãªã¼ããããã£ã¼ã«ãã®ä¸ã§ã¨ã¹ã±ã¼ããæ½ãæåã§ãããã©ã«ãã§ã¯ã¯ãªã¼ãæå (C<">) ã¨åãã - -=item sep_char - -ãã£ã¼ã«ããåºåãæåã§ãããã©ã«ãã¯ã³ã³ã (C<,>)ã - -=item binary - -ãã®å±æ§å¤ãç (TRUE) ãªãã°ãã¯ãªã¼ããããã£ã¼ã«ãã®ä¸ã§ãã¤ããªæåã使ç¨ãããã¨ãã§ããããã®ãã¤ããªæåã«ã¯ã©ã¤ã³ãã£ã¼ãããã£ãªãã¸ãªã¿ã¼ã³ããã㦠NUL ãã¤ããå«ã¾ãã¦ããï¼ NUL ãã¤ã㯠C<"0> ã¨ãã¦ã¨ã¹ã±ã¼ãããªãã¦ã¯ãªããªãï¼ãããã©ã«ãã§ããã®æ©è½ã¯ãªãã - -=item types - -ã«ã©ã ã®å½¢å¼ï¼ãã®å±æ§å¤ã¯ãããã¾å¾è¿°ã® I<types> ã¡ã½ããã«æ¸¡ããããI<types> ã¡ã½ããã使ç¨ããå ´åãé¤ãããã®å±æ§å¤ãè¨å®ãã¦ã¯ãªããªãã詳ããã¯ãå¾è¿°ã® I<types> ã¡ã½ããã®èª¬æãåç §ã - -=item always_quote - -ãã£ã¼ã«ãå ã®ããã¹ããåºåãæåãå«ããããªå ´åãªã©ããã®å¿ è¦ãããéã«ã®ã¿ããã©ã«ãã§ã¯ãã£ã¼ã«ãã¯ã¯ãªã¼ãã§åºåãããããã®å±æ§å¤ãç TRUE ã«è¨å®ããã¨ãå ¨ã¦ã®ãã£ã¼ã«ããã¯ãªã¼ããããããã®æ©è½ã¯å¤é¨ã¢ããªã±ã¼ã·ã§ã³ãç¨ããå ´åã«ä¾¿å©ã§ãããï¼ Text::CVS_XS ã使ããªãå¯åæ³ãªããã°ã©ãã®ããã«ã:-) - -=back - -ããããã¾ã¨ããã¨ã - - $csv = Text::CSV_XS->new(); - -ã¯ã以ä¸ã¨åãã§ããï¼ - - $csv = Text::CSV_XS->new({ - 'quote_char' => '"', - 'escape_char' => '"', - 'sep_char' => ',', - 'binary' => 0 - }); - -=item combine - - $status = $csv->combine(@columns); - -ãã®ãªãã¸ã§ã¯ãé¢æ°ã¯ãå¼æ°ãã CVS æååãçµã¿ç«ã¦ãæåã失æã®ã¹ãã¼ã¿ã¹ãè¿ãã失æããã®ã¯ãããããå¼æ°ã足ããªããä¸æ£ãªæååãå¼æ°ãå«ãããã§ããããæåããå ´åã C<string()> ã«ãã£ã¦çµã¿ç«ã¦ã CSV æååãå¾ããã¨ãã§ããã失æããå ´åãC<string()> 㯠æªå®ç¾©ãè¿ã C<error_input()> ã«ãã£ã¦ç¡å¹ã ã£ãå¼æ°ãå¾ããã¨ãã§ããã - -=item print - - $status = $csv->print($io, $columns); - -combine ã¨ä¼¼ã¦ãããããã®ã¡ã½ããã¯é åãªãã¡ã¬ã³ã¹ï¼é åã§ã¯ãªãï¼ãå ¥åããããã¨ãæå¾ ããï¼çµã¿ç«ã¦ã CSV æååãã¾ã£ããä½ããªãï¼I<$io> ãªãã¸ã§ã¯ãã¸ç´ã¡ã«æ¸ãè¾¼ããããã§ãI<print> ã¡ã½ããã«ä¸ããã®ã¯é常ãI<$io> ãªãã¸ã§ã¯ãã é¡ä¼¼ããä»ã®ãªãã¸ã§ã¯ãã§ããã注æãã¹ãäºã¨ãã¦ããã®å¼ã³åºãã§æ¬¡ã®æ¹æ³ã¯ééãã§ããï¼ - - - open(FILE, ">whatever"); - $status = $csv->print(\*FILE, $columns); - -C<\*FILE> ã°ããã¯ãªãã¸ã§ã¯ãã§ã¯ãªãã®ã§ãprint ã¡ã½ãããå®è¡ãããã¨ãã§ããªãã解決æ¹æ³ã¯ IO:File ãªãã¸ã§ã¯ãã使ç¨ããã IO::Wrap ãªãã¸ã§ã¯ãã®ä¸ã¸ã°ãããé è½ãã¦ãã¾ããã¨ã§ããã詳細ã¯ãL<IO::File(3)> 㨠L<IO::Wrap(3)> ãåç §ã - -ããã©ã¼ãã³ã¹ä¸ã®çç±ããããã® print ã¡ã½ããã¯çµã¿ç«ã¦ã CSV æååãå¤é¨ã¸æä¾ããªããã¨ããã I<$csv-E<gt>string()>, I<$csv-E<gt>status()>, I<$csv->fields()>, ãã㦠I<$csv-E<gt>error_input()> ã¯ããã®ã¡ã½ããã®å¾ã§æå³ããªããªãã - -=item string - - $line = $csv->string(); - -ãã®ãªãã¸ã§ã¯ãé¢æ°ã¯ã C<parse()> ã¸ã®å ¥åãããã®ã C<combine()> ã§çµã¿ç«ã¦ããã CSV æååãããããä½ã§ããç´åã®ãã®ãè¿ãã - -=item parse - - $status = $csv->parse($line); - -ãã®ãªãã¸ã§ã¯ãé¢æ°ã¯ CSV æååããã£ã¼ã«ãã«åãåãã¦ããããå¾ã«æåã失æã®ã¹ãã¼ã¿ã¹ãè¿ãã失æããã®ã¯ãå¼æ°ã®ä¸è¶³ãä¸ãããã CSV æååãä¸é©åãªãã©ã¼ãããã ããã§ããããæåããå ´åã«ã¯ãC<fields()> ã¡ã½ããã«ãã£ã¦åãåãããããã£ã¼ã«ããå¾ãããã失æã®å ´åã«ã¯ã C<fields()> ã¯æªå®ç¾©å¤ãè¿ã C<error_input()> ã«ãã£ã¦ä¸æ£ãªå¼æ°ãå¾ããã¨ãã§ããã - -ã«ã©ã ã®å½¢å¼ãè¨å®ããããã«ãI<types()> ã¡ã½ããã使ãã¹ãã§ãããå¾è¿°ã®èª¬æãåç §ã - - -=item getline - - $columns = $csv->getline($io); - -ãã㯠print ã¨å¯¾ããªããã®ã§ãparse ã combine ã®å¯¾ã¨ãªããããªãã®ã ï¼ IO ãªãã¸ã§ã¯ã $IOã«ãã㦠$IO->getline() ãç¨ãã¦ï¼è¡ãèªã¿åºãããã®ï¼è¡ããã¼ã¹ãã¦é åãªãã¡ã¬ã³ã¹ã«ç´ããããã®é åãªãã¡ã¬ã³ã¹ãè¿ããããã失æããå ´åã«ã¯ undef ãè¿ãããã - -ç¹°ãè¿ãã«ãªããã I<$csv-E<gt>string()>, I<$csv-E<gt>fields()>, ãã㦠I<$csv-E<gt>status()> ã¡ã½ããã¯ãã®ã¡ã½ããã®å¾ã§ã¯æå³ããªããªãã - -=item types - - $csv->types(\@tref); - -ãã®ã¡ã½ããã¯ã縦è¡ãæå®ãããå½¢å¼ã¸å¼·å¶çã«å¤æããã®ã«ç¨ããããã¨ãã°ãæ´æ°å¤ã§è¡¨ç¾ãããï¼ã«ã©ã ãå精度æ°å½¢å¼ã®ï¼ã«ã©ã ãæååã®ï¼ã«ã©ã ããã£ãå ´åã¯ã次ãå®è¡ãããã¨ã«ãªãã ãã - - $csv->types([Text::CSV_XS::IV(), - Text::CSV_XS::NV(), - Text::CSV_XS::NV(), - Text::CSV_XS::PV()]); - -ã«ã©ã å½¢å¼ããã³ã¼ãããã¨ãã®ã¿ãè¨ãæãã㨠I<parse()> 㨠I<getline()> ã¡ã½ããã使ãã¨ãã«ã®ã¿ããã®ã«ã©ã å½¢å¼ãç¨ããããã - - -ã«ã©ã ã¿ã¤ãã解é¤ããã®ã¯æ¬¡ã®ããã«ãã - - $csv->types(undef); - -ãããã¯ã¾ããç¾å¨ã®å½¢å¼ãå¾ãã«ã¯æ¬¡ã®æ¹æ³ãæ¡ã - - $types = $csv->types(); - -=item fields - - @columns = $csv->fields(); - -ãã®ãªãã¸ã§ã¯ãé¢æ°ã¯ã C<combine()> ã¸ã®å ¥åå¤ã C<parse()> ããå¾ãããåãåãããããã£ã¼ã«ã群ãããããä½ã§ããç´åã®ãã®ãè¿ãã - -=item status - - $status = $csv->status(); - -This object function returns success (or failure) of C<combine()> or -C<parse()>, whichever was called more recently. -ãã®ãªãã¸ã§ã¯ãé¢æ°ã¯ã C<combine()> ã C<parse()> ããããä½ã§ããç´åã®ã¡ã½ãããæåï¼ãããã¯å¤±æï¼ãããã©ãããè¿ãã - -=item error_input - - $bad_argument = $csv->error_input(); - -ãã®ãªãã¸ã§ã¯ãé¢æ°ã¯ãC<combine()> ã C<parse()> ãããããä½ã§ããç´åã®ã¡ã½ãããã¨ã©ã¼ã¨ãªã£ãå¼æ°ï¼ããããã°ï¼ãè¿ãã - -=back - -=head1 ä¾ - - require Text::CSV_XS; - - my $csv = Text::CSV_XS->new; - - my $column = ''; - my $sample_input_string = '"I said, ""Hi!""",Yes,"",2.34,,"1.09"'; - if ($csv->parse($sample_input_string)) { - my @field = $csv->fields; - my $count = 0; - for $column (@field) { - print ++$count, " => ", $column, "\n"; - } - print "\n"; - } else { - my $err = $csv->error_input; - print "parse() failed on argument: ", $err, "\n"; - } - - my @sample_input_fields = ('You said, "Hello!"', - 5.67, - 'Surely', - '', - '3.14159'); - if ($csv->combine(@sample_input_fields)) { - my $string = $csv->string; - print $string, "\n"; - } else { - my $err = $csv->error_input; - print "combine() failed on argument: ", $err, "\n"; - } - -=head1 注æ - -ãã®ã¢ã¸ã¥ã¼ã«ã¯çå®ä¸ã® CVS ãã©ã¼ããããå ã«ãã¦ãããããã®ãã©ã¼ããããæãä¸è¬çãªãã®ã¨ã¯è¨ãé£ããããããªãã - -=over 4 - -=item 1 - -CVS ãã£ã¼ã«ãã®ä¸ã«ç´ãããã¨ãã§ããæåã«ã¯ã 0x09 (tab) 㨠of 0x20 (space) ãã 0x7E (tilde)ã®å æ¬çãªç¯å²ã¨ãå«ãããã¤ããªã¢ã¼ãã§ã¯ã¯ãªã¼ãããããã£ã¼ã«ãã®ä¸ã«ããã¦å ¨ã¦ã®æåãåãä»ããã - -=item 2 - -CSV ã®ãã£ã¼ã«ãã¯ãäºéå¼ç¨ç¬¦ï¼quote charï¼ã§æã¾ããã¹ãã§ããã - -=item 3 - -CVS ã®ãã£ã¼ã«ãã®ä¸ã«ã³ã³ã(separator char)ãããå ´åã¯ãäºéå¼ç¨ç¬¦ã§æã¾ããªããã°ãªããªãã - -=item 4 - -CVS ãã£ã¼ã«ãã®ä¸ã«äºéå¼ç¨ç¬¦ãåãè¾¼ãå ´åã¯ãä¸å¯¾ã¨ãªã£ãäºéå¼ç¨ç¬¦ã®éã«æã¾ããªããã°ãªããªãããã¤ããªã¢ã¼ãã§ã¯ç¹ã«ã NUL ãã¤ãã示ã C<"0> ãç¨ããã¹ãã§ããã - -=item 5 - -CSV æååã¯ã 0x0A (ã©ã¤ã³ãã£ã¼ã) ããã㯠0x0D + 0x0A(ãã£ãªãã¸ãªã¿ã¼ã³ + ã©ã¤ã³ãã£ã¼ã)ã§çµããã¹ãã§ããã - -=head1 AUTHOR - -Alan Citterman F<E<lt>alan****@mfgrt*****<gt>> ãããã® Perl ã¢ã¸ã¥ã¼ã«ãæåã«æ¸ãããAlan 㸠Text::CSV_XS ã«é¢ããã¡ã¼ã«ãã©ããéããªãã§æ¬²ããããªããªããä»ã§ã¯ãã®ã¢ã¸ã¥ã¼ã«ã®ä¸»è¦é¨åãå ãã C ã³ã¼ãé¨åã«ã¤ãã¦ãå½¼ã¯é¢ä¸ãã¦ããªãããã§ããã - -Jochen Wiedmann F<E<lt>joe****@ispso*****<gt>> ããã¨ã³ã³ã¼ãã¨ãã³ã¼ãã®ã«ã¼ãã³ãæéç¶æ ãã·ã³ãå®è£ ãã C ã³ã¼ãã§æ¸ãç´ããã¯ãªã¼ããã¨ã¹ã±ã¼ããããã¦ã»ãã¬ã¼ã¿ã¼æåå¤æ°ããã¤ããªã¢ã¼ãããã㦠print 㨠getline ã¡ã½ãããå ããã - -=head1 SEE ALSO - -L<perl(1)>, L<IO::File(3)>, L<IO::Wrap(3)> - -=head1 Translator into Japanese (翻訳è ) - -anahori (at users.sourceforge.jp) - -Japanized Perl Resources Project (L<http://sourceforge.jp/projects/perldocjp/>) - -=cut \ No newline at end of file